package com.todo.strategy.online.application.convert;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.google.api.client.util.Lists;
import com.todo.common.common.entity.BaseUserVO;
import com.todo.common.common.entity.response.page.PageResult;
import com.todo.common.common.enums.AllowedCommentEnum;
import com.todo.common.common.enums.SourceEnum;
import com.todo.common.common.enums.biz.PrivateTypeEnum;
import com.todo.common.utils.DateUtils;
import com.todo.common.utils.TodoCommonUtils;
import com.todo.strategy.common.enums.*;
import com.todo.strategy.online.application.entity.bo.*;
import com.todo.strategy.online.application.entity.condition.PlanSetConditionBO;
import com.todo.strategy.online.application.entity.condition.StrategyInfoConditionBO;
import com.todo.strategy.online.iface.backend.request.QueryUserStrategyByConditionReq;
import com.todo.strategy.online.iface.backend.response.QueryUserStrategyByConditionResp;
import com.todo.strategy.online.iface.backend.response.UserStrategyDetailResp;
import com.todo.strategy.online.iface.backend.response.UserStrategyRelationResp;
import com.todo.strategy.online.iface.model.MemoRelationContentModelParam;
import com.todo.strategy.online.iface.model.MemoTemplateContentModelParam;
import com.todo.strategy.online.iface.request.*;
import com.todo.strategy.online.iface.response.*;
import com.todo.strategy.online.infrastructure.entity.condition.PlanSetCondition;
import com.todo.strategy.online.infrastructure.entity.condition.StrategyInfoCondition;
import com.todo.strategy.online.infrastructure.entity.domain.PlatformStrategyDO;
import com.todo.strategy.online.infrastructure.entity.model.MemoTemplateContentModel;
import com.todo.strategy.online.infrastructure.entity.model.MemoUserRelationContentModel;
import com.todo.strategy.online.infrastructure.entity.po.*;
import com.todo.strategy.online.infrastructure.helper.es.entity.BasicStrategyEntity;
import com.todo.strategy.online.service.api.response.*;
import com.todo.user.api.response.BaseUserInfoResponse;
import org.apache.commons.collections4.CollectionUtils;

import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author azhebuxing
 * @date 2024/5/19 16:11
 * @description
 */
public class StrategyConvert {


    public static PlanSetBO convertToPlanSetBO(InsertPlanSetParam param) {
        if (param == null) {
            return null;
        }
        PlanSetBO insertPlanSetRequest = new PlanSetBO();
        insertPlanSetRequest.setPlanId(TodoCommonUtils.buildLongGuid());
        insertPlanSetRequest.setUserId(param.get_user().getUserId());
        insertPlanSetRequest.setPlanCity(param.getPlanCity());
        insertPlanSetRequest.setPlanMoneySpend(param.getPlanMoneySpend());
        insertPlanSetRequest.setPlanType(StrategyTypeEnum.getByType(param.getPlanType()));
        insertPlanSetRequest.setIsPrivate(PrivateTypeEnum.getByType(param.getIsPrivate()));
        insertPlanSetRequest.setStartPlanTime(param.getStartPlanTime());
        insertPlanSetRequest.setEndPlanTime(param.getEndPlanTime());
        insertPlanSetRequest.setIsTravel(param.getIsTravel());
        insertPlanSetRequest.setMainImg(param.getMainImg());
        insertPlanSetRequest.setTitle(param.getTitle());
        insertPlanSetRequest.setDesc(param.getDesc());

        return insertPlanSetRequest;
    }

    public static PlanSetBO convertToPlanSetBO(UpdatePlanSetParam param) {
        if (param == null) {
            return null;
        }
        PlanSetBO updatePlanSetRequest = new PlanSetBO();
        updatePlanSetRequest.setPlanId(param.getPlanId());
        updatePlanSetRequest.setUserId(param.get_user().getUserId());
        updatePlanSetRequest.setPlanCity(param.getPlanCity());
        updatePlanSetRequest.setPlanMoneySpend(param.getPlanMoneySpend());
        updatePlanSetRequest.setPlanType(StrategyTypeEnum.getByType(param.getPlanType()));
        updatePlanSetRequest.setIsPrivate(PrivateTypeEnum.getByType(param.getIsPrivate()));
        updatePlanSetRequest.setStartPlanTime(param.getStartPlanTime());
        updatePlanSetRequest.setEndPlanTime(param.getEndPlanTime());
        updatePlanSetRequest.setIsTravel(param.getIsTravel());
        updatePlanSetRequest.setMainImg(param.getMainImg());
        updatePlanSetRequest.setTitle(param.getTitle());
        updatePlanSetRequest.setDesc(param.getDesc());
        return updatePlanSetRequest;
    }


    private static TravelStatusEnum calTravelStatusByTime(Date startPlanTime, Date endPlanTime) {
        if (startPlanTime == null || endPlanTime == null) {
            return TravelStatusEnum.NOT_STARTED;
        }
        Date today = new Date();
        if (today.before(startPlanTime)) {
            return TravelStatusEnum.NOT_STARTED;
        }
        if (today.after(endPlanTime)) {
            return TravelStatusEnum.ENDED;
        }
        return TravelStatusEnum.IN_PROGRESS;
    }

    public static PageResult<PlanSetInfoVO> buildPagePlanSetBaseResponseList(BaseUserInfoResponse userInfoResponse, PageResult<PlanSetBO> result) {
        if (userInfoResponse == null || result == null) {
            return null;
        }
        if (result.getResults() == null) {
            return PageResult.of(null, result.getPageNum(), result.getPageSize(), result.getTotal());
        }
        BaseUserVO baseUserVO = BuildBaseUserVO(userInfoResponse);
        List<PlanSetInfoVO> planSetInfoVOList = new ArrayList<>();
        for (PlanSetBO planSetBO : result.getResults()) {
            PlanSetInfoVO planSetInfoVO = new PlanSetInfoVO();
            planSetInfoVO.setBaseUserVO(baseUserVO);
            planSetInfoVO.setPlanId(planSetBO.getPlanId());
            planSetInfoVO.setPlanCity(planSetBO.getPlanCity());
            planSetInfoVO.setPlanMoneySpend(planSetBO.getPlanMoneySpend());
            planSetInfoVO.setPlanType(planSetBO.getPlanType() == null ? null : planSetBO.getPlanType().getType());
            planSetInfoVO.setStartPlanTime(planSetBO.getStartPlanTime());
            planSetInfoVO.setEndPlanTime(planSetBO.getEndPlanTime());
            planSetInfoVO.setIsTravel(planSetBO.getIsTravel());
            planSetInfoVO.setTitle(planSetBO.getTitle());
            planSetInfoVO.setMainImg(planSetBO.getMainImg());
            planSetInfoVO.setStatus(planSetBO.getStatus() == null ? null : planSetBO.getStatus().getType());
            planSetInfoVO.setRelationCount(planSetBO.getRelationCount());
            planSetInfoVO.setTravelStatus(planSetBO.getTravelStatus() == null ? TravelStatusEnum.NOT_STARTED.getType() : planSetBO.getTravelStatus());
            planSetInfoVO.setTravelStatusStr(planSetBO.getTravelStatus() == null ? TravelStatusEnum.NOT_STARTED.getName() : TravelStatusEnum.getByType(planSetBO.getTravelStatus()).getName());
            planSetInfoVOList.add(planSetInfoVO);
        }
        return new PageResult<>(planSetInfoVOList, result.getPageNum(), result.getPageSize(), result.getTotal());
    }

    public static List<PlanSetInfoVO> buildPagePlanSetBaseResponseList(BaseUserInfoResponse userInfoResponse, List<PlanSetBO> responseList) {
        if (userInfoResponse == null || responseList == null) {
            return null;
        }
        List<PlanSetInfoVO> result = new ArrayList<>();
        BaseUserVO baseUserVO = BuildBaseUserVO(userInfoResponse);
        for (PlanSetBO planSetBaseResponse : responseList) {
            PlanSetInfoVO planSetInfoVO = new PlanSetInfoVO();
            planSetInfoVO.setBaseUserVO(baseUserVO);
            planSetInfoVO.setPlanId(planSetBaseResponse.getPlanId());
            planSetInfoVO.setPlanCity(planSetBaseResponse.getPlanCity());
            planSetInfoVO.setPlanMoneySpend(planSetBaseResponse.getPlanMoneySpend());
            planSetInfoVO.setPlanType(planSetBaseResponse.getPlanType() == null ? null : planSetBaseResponse.getPlanType().getType());
            planSetInfoVO.setStartPlanTime(planSetBaseResponse.getStartPlanTime());
            planSetInfoVO.setEndPlanTime(planSetBaseResponse.getEndPlanTime());
            planSetInfoVO.setIsTravel(planSetBaseResponse.getIsTravel());
            planSetInfoVO.setTitle(planSetBaseResponse.getTitle());
            planSetInfoVO.setMainImg(planSetBaseResponse.getMainImg());
            planSetInfoVO.setStatus(planSetBaseResponse.getStatus().getType());
            planSetInfoVO.setRelationCount(planSetBaseResponse.getRelationCount());
            planSetInfoVO.setTravelStatus(planSetBaseResponse.getTravelStatus() == null ? TravelStatusEnum.NOT_STARTED.getType() : planSetBaseResponse.getTravelStatus());
            planSetInfoVO.setTravelStatusStr(planSetBaseResponse.getTravelStatus() == null ? TravelStatusEnum.NOT_STARTED.getName() : TravelStatusEnum.getByType(planSetBaseResponse.getTravelStatus()).getName());
            result.add(planSetInfoVO);
        }
        return result;
    }


    public static PlatformStrategyDetailVO convertToPlatformStrategyDetailVO(PlatformStrategyDetailBO platformStrategyDetailBO) {
        if (platformStrategyDetailBO == null) {
            return null;
        }
        BaseUserVO baseUserVO = new BaseUserVO();
        baseUserVO.setUserId("0");
        baseUserVO.setUserName("tuduAdmin");
        baseUserVO.setUserNikeName("途度平台攻略");
        PlatformStrategyDetailVO platformStrategyDetailVO = new PlatformStrategyDetailVO();
        platformStrategyDetailVO.setBaseUserVO(baseUserVO);
        platformStrategyDetailVO.setPlatformStrategyInfoVO(convertToPlatformStrategyInfoVO(platformStrategyDetailBO));
        platformStrategyDetailVO.setPlatformStrategyDetail(convertToPlatformStrategyDetailVODetail(platformStrategyDetailBO));

        return platformStrategyDetailVO;
    }

    private static PlatformStrategyDetailVO.PlatformStrategyDetail convertToPlatformStrategyDetailVODetail(PlatformStrategyDetailBO platformStrategyDetailBO) {
        if (platformStrategyDetailBO == null) {
            return null;
        }
        PlatformStrategyDetailVO.PlatformStrategyDetail platformStrategyDetail = new PlatformStrategyDetailVO.PlatformStrategyDetail();
        PlatformStrategyExtendBO platformStrategyExtendBO = platformStrategyDetailBO.getPlatformStrategyExtendBO();
        platformStrategyDetail.setAgeSuggest(platformStrategyExtendBO.getAgeSuggest());
        if (platformStrategyExtendBO.getSecuritySuggest() != null) {
            PlatformStrategyExtendBO.SecuritySuggest securitySuggest = platformStrategyExtendBO.getSecuritySuggest();
            PlatformStrategyDetailVO.SecuritySuggest resultSecuritySuggest = new PlatformStrategyDetailVO.SecuritySuggest();
            resultSecuritySuggest.setAssistance(securitySuggest.getAssistance());
            resultSecuritySuggest.setBaseAttention(securitySuggest.getBaseAttention());
            resultSecuritySuggest.setOutDoorAttention(securitySuggest.getOutDoorAttention());
            resultSecuritySuggest.setTravelLimit(securitySuggest.getTravelLimit());
            platformStrategyDetail.setSecuritySuggest(resultSecuritySuggest);
        }
        if (platformStrategyExtendBO.getTravelSuggest() != null) {
            PlatformStrategyExtendBO.TravelSuggest travelSuggest = platformStrategyExtendBO.getTravelSuggest();
            PlatformStrategyDetailVO.TravelSuggest resultTravelSuggest = new PlatformStrategyDetailVO.TravelSuggest();
            resultTravelSuggest.setTravelSuggest(travelSuggest.getTravelSuggest());
            resultTravelSuggest.setSeasonSuggest(travelSuggest.getSeasonSuggest());
            resultTravelSuggest.setEssentialItems(travelSuggest.getEssentialItems());
            resultTravelSuggest.setDisclose(travelSuggest.getDisclose());
            resultTravelSuggest.setSuggestCarry(travelSuggest.getSuggestCarry());
            platformStrategyDetail.setTravelSuggest(resultTravelSuggest);
        }
        if (platformStrategyExtendBO.getInstructions() != null) {
            PlatformStrategyExtendBO.Instructions instructions = platformStrategyExtendBO.getInstructions();
            PlatformStrategyDetailVO.Instructions resultInstructions = new PlatformStrategyDetailVO.Instructions();
            resultInstructions.setLocalCulture(instructions.getLocalCulture());
            resultInstructions.setDifficultyLevel(instructions.getDifficultyLevel());
            platformStrategyDetail.setInstructions(resultInstructions);
        }
        if (platformStrategyExtendBO.getExtra() != null) {
            platformStrategyDetail.setImgList(platformStrategyExtendBO.getExtra().getImgList());
        }
        return platformStrategyDetail;
    }

    private static PlatformStrategyInfoVO convertToPlatformStrategyInfoVO(PlatformStrategyDetailBO platformStrategyDetailBO) {
        if (platformStrategyDetailBO == null || platformStrategyDetailBO.getPlatformStrategyBO() == null) {
            return null;
        }
        PlatformStrategyInfoVO platformStrategyInfoVO = new PlatformStrategyInfoVO();
        PlatformStrategyBO platformStrategyBO = platformStrategyDetailBO.getPlatformStrategyBO();
        platformStrategyInfoVO.setTitle(platformStrategyBO.getTitle());
        platformStrategyInfoVO.setTravelTimeType(platformStrategyBO.getTravelTimeType() == null ? null : platformStrategyBO.getTravelTimeType().getName());
        platformStrategyInfoVO.setTimeCost(platformStrategyBO.getTimeCost());
        platformStrategyInfoVO.setMoneyCost(platformStrategyBO.getMoneyCost());
        platformStrategyInfoVO.setMainImg(platformStrategyBO.getMainImg());
        platformStrategyInfoVO.setScore(platformStrategyBO.getScore());
        platformStrategyInfoVO.setStrategyType(platformStrategyBO.getStrategyType() == null ? null : platformStrategyBO.getStrategyType().getName());
        platformStrategyInfoVO.setReferenceCount(platformStrategyBO.getReferenceCount());
        platformStrategyInfoVO.setRecommendDesc(platformStrategyBO.getRecommendDesc());
        platformStrategyInfoVO.setProvince(platformStrategyBO.getProvince());
        platformStrategyInfoVO.setCity(platformStrategyBO.getCity());
        platformStrategyInfoVO.setRecommendMonth(platformStrategyBO.getRecommendMonth());
        platformStrategyInfoVO.setIsFree(platformStrategyBO.getIsFree());
        platformStrategyInfoVO.setAllowComment(platformStrategyBO.getAllowComment() == null ? null : platformStrategyBO.getAllowComment().getType());
        platformStrategyInfoVO.setStrategyId(platformStrategyBO.getStrategyId());
        return platformStrategyInfoVO;
    }


    public static StrategyBaseVO convertToStrategyBaseVO(PlatformStrategyBO platformStrategyBO, BaseUserInfoResponse userInfoResponse) {
        if (platformStrategyBO == null) {
            return null;
        }
        StrategyBaseVO strategyBaseVO = new StrategyBaseVO();
        strategyBaseVO.setBaseUserVO(BuildBaseUserVO(userInfoResponse));
        strategyBaseVO.setTitle(platformStrategyBO.getTitle());
        strategyBaseVO.setStrategyType(platformStrategyBO.getStrategyType() == null ? null : platformStrategyBO.getStrategyType().getType());
        strategyBaseVO.setTimeCost(platformStrategyBO.getTimeCost());
        strategyBaseVO.setMoneyCost(platformStrategyBO.getMoneyCost());
        strategyBaseVO.setMainImg(platformStrategyBO.getMainImg());
        strategyBaseVO.setScore(platformStrategyBO.getScore());
        strategyBaseVO.setRecommendDesc(platformStrategyBO.getRecommendDesc());
        strategyBaseVO.setProvince(platformStrategyBO.getProvince());
        strategyBaseVO.setCity(platformStrategyBO.getCity());
        strategyBaseVO.setReferenceCount(platformStrategyBO.getReferenceCount());
        strategyBaseVO.setCollectCount(platformStrategyBO.getCollectCount());
        strategyBaseVO.setCommentCount(platformStrategyBO.getCommentCount());
        strategyBaseVO.setLikeCount(platformStrategyBO.getLikeCount());
        strategyBaseVO.setViewCount(platformStrategyBO.getViewCount());
        strategyBaseVO.setStrategyClassify(0);
        strategyBaseVO.setTravelMonth(platformStrategyBO.getRecommendMonth() == null ? null : platformStrategyBO.getRecommendMonth().get(0));
        strategyBaseVO.setBizId(platformStrategyBO.getStrategyId());
        strategyBaseVO.setStrategyTypeStr(platformStrategyBO.getStrategyType().getName());
        strategyBaseVO.setTravelDays(platformStrategyBO.getTravelTimeType() == null ? 0 : platformStrategyBO.getTravelTimeType().getDays());
        return strategyBaseVO;
    }

    public static PlanRelationBO convertToPlanRelationBO(InsertPlanRelationParam param) {
        if (param == null) {
            return null;
        }
        PlanRelationBO planRelationBO = new PlanRelationBO();
        planRelationBO.setBusinessId(param.getPlanId());
        planRelationBO.setTitle(param.getTitle());
        planRelationBO.setStartTime(param.getStartTime());
        planRelationBO.setTimeCost(param.getTimeCost());
        planRelationBO.setMoneyCost(param.getMoneyCost());
        planRelationBO.setRelationId(param.getRelationId());
        planRelationBO.setRelationType(StrategyRelationTypeEnum.getByType(param.getRelationType()));
        planRelationBO.setRelationName(param.getRelationName());
        planRelationBO.setPlanDay(param.getPlanDay());
        if (param.getCustomInfo() != null) {
            InsertPlanRelationParam.CustomInfo customInfo = param.getCustomInfo();
            PlanRelationBO.CustomInfo requestCustomInfo = new PlanRelationBO.CustomInfo();
            requestCustomInfo.setAddress(customInfo.getAddress());
            requestCustomInfo.setName(customInfo.getName());
            requestCustomInfo.setLat(customInfo.getLat());
            requestCustomInfo.setLon(customInfo.getLon());
            requestCustomInfo.setCustomType(customInfo.getCustomType());
            PlanRelationBO.Extra extra = new PlanRelationBO.Extra();
            extra.setCustomInfo(requestCustomInfo);
            planRelationBO.setExtra(extra);
        }
        if (param.getSuggest() != null) {
            InsertPlanRelationParam.Suggest suggest = param.getSuggest();
            PlanRelationBO.Suggest requestSuggest = new PlanRelationBO.Suggest();
            requestSuggest.setTravelPlan(suggest.getTravelPlan());
            requestSuggest.setTravelRemark(suggest.getTravelRemark());
            requestSuggest.setTravelSuggest(suggest.getTravelSuggest());
            requestSuggest.setNecessaryItems(suggest.getNecessaryItems());
            planRelationBO.setSuggest(requestSuggest);
        }
        planRelationBO.setRemark(param.getRemark());
        return planRelationBO;
    }

    public static List<PlanRelationBO> convertToPlanRelationBOList(DuplicatePlanRelationParam param) {
        if (param == null || param.getDuplicateDataList() == null) {
            return null;
        }
        List<PlanRelationBO> planRelationBOList = new ArrayList<>();
        for (DuplicatePlanRelationParam.DuplicateData duplicateData : param.getDuplicateDataList()) {
            PlanRelationBO planRelationBO = new PlanRelationBO();
            planRelationBO.setBusinessId(param.getPlanId());
            planRelationBO.setTitle(duplicateData.getTitle());
            planRelationBO.setStartTime(duplicateData.getStartTime());
            planRelationBO.setTimeCost(duplicateData.getTimeCost());
            planRelationBO.setMoneyCost(duplicateData.getMoneyCost());
            planRelationBO.setRelationId(duplicateData.getRelationId());
            planRelationBO.setRelationType(StrategyRelationTypeEnum.getByType(duplicateData.getRelationType()));
            planRelationBO.setRelationName(duplicateData.getRelationName());
            if (duplicateData.getCustomInfo() != null) {
                DuplicatePlanRelationParam.CustomInfo customInfo = duplicateData.getCustomInfo();
                PlanRelationBO.CustomInfo requestCustomInfo = new PlanRelationBO.CustomInfo();
                requestCustomInfo.setAddress(customInfo.getAddress());
                requestCustomInfo.setName(customInfo.getName());
                requestCustomInfo.setLon(customInfo.getLon());
                requestCustomInfo.setLat(customInfo.getLat());
                requestCustomInfo.setCustomType(customInfo.getCustomType());
                PlanRelationBO.Extra extra = new PlanRelationBO.Extra();
                extra.setCustomInfo(requestCustomInfo);
                planRelationBO.setExtra(extra);
            }
            if (duplicateData.getSuggest() != null) {
                DuplicatePlanRelationParam.Suggest suggest = duplicateData.getSuggest();
                PlanRelationBO.Suggest requestSuggest = new PlanRelationBO.Suggest();
                requestSuggest.setTravelPlan(suggest.getTravelPlan());
                requestSuggest.setTravelRemark(suggest.getTravelRemark());
                requestSuggest.setTravelSuggest(suggest.getTravelSuggest());
                requestSuggest.setNecessaryItems(suggest.getNecessaryItems());
                planRelationBO.setSuggest(requestSuggest);
                planRelationBOList.add(planRelationBO);
            }
            planRelationBO.setRemark("");
            planRelationBO.setPlanDay(duplicateData.getPlanDay());
            planRelationBOList.add(planRelationBO);
        }
        return planRelationBOList;
    }

    public static PlanSetBO buildDuplicatePlanSetBO(PlanSetBO origin) {
        if (origin == null) {
            return null;
        }
        PlanSetBO planSetBO = new PlanSetBO();
        planSetBO.setPlanId(TodoCommonUtils.buildLongGuid());
        planSetBO.setTitle(origin.getTitle());
        planSetBO.setPlanCity(origin.getPlanCity());
        planSetBO.setPlanMoneySpend(origin.getPlanMoneySpend());
        planSetBO.setPlanType(origin.getPlanType());
        planSetBO.setDesc(origin.getDesc());
        planSetBO.setIsPrivate(PrivateTypeEnum.PUBLIC);
        planSetBO.setIsTravel(origin.getIsTravel());
        planSetBO.setMainImg(origin.getMainImg());
        planSetBO.setStartPlanTime(origin.getStartPlanTime());
        planSetBO.setEndPlanTime(origin.getEndPlanTime());
        return planSetBO;
    }


    public static List<PlanRelationBO> buildDuplicatePlanRelationBO(List<PlanRelationBO> relationResponses, Long newPlanId) {
        if (CollectionUtils.isEmpty(relationResponses) || newPlanId == null) {
            return Lists.newArrayList();
        }
        List<PlanRelationBO> planRelationBOList = Lists.newArrayList();
        for (PlanRelationBO relationResponse : relationResponses) {
            PlanRelationBO planRelationBO = new PlanRelationBO();
            planRelationBO.setBusinessId(newPlanId);
            planRelationBO.setRelationId(relationResponse.getRelationId());
            if (relationResponse.getExtra() != null && relationResponse.getExtra().getCustomInfo() != null) {
                PlanRelationBO.CustomInfo requestCustomInfo = new PlanRelationBO.CustomInfo();
                requestCustomInfo.setAddress(relationResponse.getExtra().getCustomInfo().getAddress());
                requestCustomInfo.setName(relationResponse.getExtra().getCustomInfo().getName());
                requestCustomInfo.setLat(relationResponse.getExtra().getCustomInfo().getLat());
                requestCustomInfo.setLon(relationResponse.getExtra().getCustomInfo().getLon());
                requestCustomInfo.setCustomType(relationResponse.getExtra().getCustomInfo().getCustomType());
                PlanRelationBO.Extra extra = new PlanRelationBO.Extra();
                extra.setCustomInfo(requestCustomInfo);
                planRelationBO.setExtra(extra);
            }
            if (relationResponse.getSuggest() != null) {
                PlanRelationBO.Suggest requestSuggest = new PlanRelationBO.Suggest();
                requestSuggest.setTravelPlan(relationResponse.getSuggest().getTravelPlan());
                requestSuggest.setTravelRemark(relationResponse.getSuggest().getTravelRemark());
                requestSuggest.setTravelSuggest(relationResponse.getSuggest().getTravelSuggest());
                requestSuggest.setNecessaryItems(relationResponse.getSuggest().getNecessaryItems());
                planRelationBO.setSuggest(requestSuggest);
            }
            planRelationBO.setRelationName(relationResponse.getRelationName());
            planRelationBO.setRelationType(relationResponse.getRelationType());
            planRelationBO.setRemark(relationResponse.getRemark());
            planRelationBO.setStartTime(relationResponse.getStartTime());
            planRelationBO.setTimeCost(relationResponse.getTimeCost());
            planRelationBO.setTitle(relationResponse.getTitle());
            planRelationBO.setMoneyCost(relationResponse.getMoneyCost());
            planRelationBO.setPlanDay(relationResponse.getPlanDay());
            planRelationBOList.add(planRelationBO);
        }
        return planRelationBOList;
    }

    public static PlanRelationBO convertToPlanRelationBO(UpdatePlanRelationParam param) {
        if (param == null) {
            return null;
        }
        PlanRelationBO request = new PlanRelationBO();
        request.setId(param.getId());
        request.setBusinessId(param.getPlanId());
        request.setRelationId(param.getRelationId());
        request.setRelationName(param.getRelationName());
        request.setPlanDay(param.getPlanDay());
        request.setTimeCost(param.getTimeCost());
        request.setMoneyCost(param.getMoneyCost());
        if (param.getCustomInfo() != null) {
            PlanRelationBO.CustomInfo requestCustomInfo = new PlanRelationBO.CustomInfo();
            requestCustomInfo.setAddress(param.getCustomInfo().getAddress());
            requestCustomInfo.setName(param.getCustomInfo().getName());
            requestCustomInfo.setLat(param.getCustomInfo().getLat());
            requestCustomInfo.setLon(param.getCustomInfo().getLon());
            requestCustomInfo.setCustomType(param.getCustomInfo().getCustomType());
            PlanRelationBO.Extra extra = new PlanRelationBO.Extra();
            extra.setCustomInfo(requestCustomInfo);
            request.setExtra(extra);
        }
        if (param.getSuggest() != null) {
            PlanRelationBO.Suggest requestSuggest = new PlanRelationBO.Suggest();
            requestSuggest.setTravelPlan(param.getSuggest().getTravelPlan());
            requestSuggest.setTravelRemark(param.getSuggest().getTravelRemark());
            requestSuggest.setTravelSuggest(param.getSuggest().getTravelSuggest());
            requestSuggest.setNecessaryItems(param.getSuggest().getNecessaryItems());
            request.setSuggest(requestSuggest);
        }
        request.setRelationType(StrategyRelationTypeEnum.getByType(param.getRelationType()));
        request.setStartTime(param.getStartTime());
        request.setTitle(param.getTitle());
        request.setRemark(param.getRemark());
        request.setIsTravel(param.getIsTravel());
        return request;
    }

    public static PlanRelationDetailVO buildPlanRelationDetailVO(BaseUserInfoResponse userInfoResponse, PlanSetBO planSetBO, List<PlanRelationBO> planRelationBOList) {
        if (userInfoResponse == null || planSetBO == null || CollectionUtils.isEmpty(planRelationBOList)) {
            return null;
        }
        PlanRelationDetailVO response = new PlanRelationDetailVO();
        response.setPlanId(String.valueOf(planSetBO.getPlanId()));
        response.setPlanSetInfoVO(buildPagePlanSetBaseResponse(userInfoResponse, planSetBO));
        response.setPlanRelationInfoVO(convertPlanRelationInfoVOList(planRelationBOList));
        response.setBaseUserVO(BuildBaseUserVO(userInfoResponse));
        return response;
    }

    private static BaseUserVO BuildBaseUserVO(BaseUserInfoResponse userInfoResponse) {
        if (userInfoResponse == null) {
            return null;
        }
        BaseUserVO baseUserVO = new BaseUserVO();
        baseUserVO.setUserId(String.valueOf(userInfoResponse.getUserId()));
        baseUserVO.setUserNikeName(userInfoResponse.getNickName());
        baseUserVO.setUserName(userInfoResponse.getUserName());
        baseUserVO.setUserAvatar(userInfoResponse.getHeadImg());
        return baseUserVO;
    }


    private static BaseUserVO buildPlatformDefaultUserVO() {
        // TODO 需要创建一个默认的平台用户信息作为前台展示
        BaseUserVO baseUserVO = new BaseUserVO();
        baseUserVO.setUserId("default");
        baseUserVO.setUserName("default");
        baseUserVO.setUserNikeName("default");
        baseUserVO.setUserAvatar("default");
        return baseUserVO;
    }

    private static List<PlanRelationInfoVO> convertPlanRelationInfoVOList(List<PlanRelationBO> planRelationBOList) {
        if (CollectionUtils.isEmpty(planRelationBOList)) {
            return Lists.newArrayList();
        }
        return planRelationBOList.stream().map(StrategyConvert::convertToPlanRelationInfoVO).collect(Collectors.toList());
    }

    private static PlanRelationInfoVO convertToPlanRelationInfoVO(PlanRelationBO planRelationBO) {
        if (planRelationBO == null) {
            return null;
        }
        PlanRelationInfoVO planRelationInfoVO = new PlanRelationInfoVO();
        planRelationInfoVO.setTitle(planRelationBO.getTitle());
        planRelationInfoVO.setId(planRelationBO.getId());
        planRelationInfoVO.setPlanDay(planRelationBO.getPlanDay());
        planRelationInfoVO.setRelationName(planRelationBO.getRelationName());
        planRelationInfoVO.setRelationType(planRelationBO.getRelationType().getType());
        planRelationInfoVO.setRemark(planRelationBO.getRemark());
        if (planRelationBO.getExtra() != null && planRelationBO.getExtra().getCustomInfo() != null) {
            PlanRelationBO.CustomInfo customInfo = planRelationBO.getExtra().getCustomInfo();
            planRelationInfoVO.setAddress(customInfo.getAddress());
        }
        if (planRelationBO.getSuggest() != null) {
            PlanRelationBO.Suggest suggest = planRelationBO.getSuggest();
            PlanRelationInfoVO.Suggest suggestVO = new PlanRelationInfoVO.Suggest();
            suggestVO.setTravelPlan(suggest.getTravelPlan());
            suggestVO.setTravelRemark(suggest.getTravelRemark());
            suggestVO.setTravelSuggest(suggest.getTravelSuggest());
            suggestVO.setNecessaryItems(suggest.getNecessaryItems());
            planRelationInfoVO.setSuggest(suggestVO);
        }
        planRelationInfoVO.setTimeCost(planRelationBO.getTimeCost());
        planRelationInfoVO.setMoneyCost(planRelationBO.getMoneyCost());
        planRelationInfoVO.setStartTime(planRelationBO.getStartTime());
        planRelationInfoVO.setRelationId(planRelationBO.getRelationId());
        return planRelationInfoVO;
    }


    public static PlanSetInfoVO buildPagePlanSetBaseResponse(BaseUserInfoResponse userInfoResponse, PlanSetBO planSetBO) {
        if (userInfoResponse == null || planSetBO == null) {
            return null;
        }
        BaseUserVO baseUserVO = BuildBaseUserVO(userInfoResponse);
        PlanSetInfoVO planSetInfoVO = new PlanSetInfoVO();
        planSetInfoVO.setBaseUserVO(baseUserVO);
        planSetInfoVO.setPlanId(planSetBO.getPlanId());
        planSetInfoVO.setPlanCity(planSetBO.getPlanCity());
        planSetInfoVO.setPlanMoneySpend(planSetBO.getPlanMoneySpend());
        planSetInfoVO.setPlanType(planSetBO.getPlanType() == null ? null : planSetBO.getPlanType().getType());
        planSetInfoVO.setStartPlanTime(planSetBO.getStartPlanTime());
        planSetInfoVO.setEndPlanTime(planSetBO.getEndPlanTime());
        planSetInfoVO.setIsTravel(planSetBO.getIsTravel());
        planSetInfoVO.setTitle(planSetBO.getTitle());
        planSetInfoVO.setMainImg(planSetBO.getMainImg());
        planSetInfoVO.setStatus(planSetBO.getStatus() == null ? null : planSetBO.getStatus().getType());
        planSetInfoVO.setRelationCount(planSetBO.getRelationCount());
        planSetInfoVO.setTravelStatus(planSetBO.getTravelStatus() == null ? TravelStatusEnum.NOT_STARTED.getType() : planSetBO.getTravelStatus());
        planSetInfoVO.setTravelStatusStr(planSetBO.getTravelStatus() == null ? TravelStatusEnum.NOT_STARTED.getName() : TravelStatusEnum.getByType(planSetBO.getTravelStatus()).getName());
        return planSetInfoVO;
    }

    public static PlanContentBO convertToPlanContentBO(InsertPlanContentParam param) {
        if (param == null) {
            return null;
        }
        PlanContentBO planContentBO = new PlanContentBO();
        planContentBO.setUserId(param.get_user().getUserId());
        planContentBO.setPlanId(param.getPlanId());
        planContentBO.setTitle(param.getTitle());
        planContentBO.setContent(param.getContent());
        if (param.getTravelSuggest() != null) {
            PlanContentBO.Suggest suggest = new PlanContentBO.Suggest();
            suggest.setTravelSuggest(param.getTravelSuggest().getTravelSuggest());
            suggest.setSightSuggest(param.getTravelSuggest().getSightSuggest());
            suggest.setDefectSuggest(param.getTravelSuggest().getDefectSuggest());
            suggest.setDisclose(param.getTravelSuggest().getDisclose());
            planContentBO.setTravelSuggest(suggest);
        }
        planContentBO.setScore(param.getScore());
        PlanContentBO.ExtraInfo extraInfo = new PlanContentBO.ExtraInfo();
        extraInfo.setMoneyCost(param.getMoneyCost());
        extraInfo.setTimeCost(param.getTimeCost());
        extraInfo.setImgList(param.getImgList());
        planContentBO.setExtraInfo(extraInfo);
        planContentBO.setPlanRelationId(param.getPlanRelationId());
        return planContentBO;
    }

    public static PlanContentBO convertToPlanContentBO(UpdatePlanContentParam param) {
        if (param == null) {
            return null;
        }
        PlanContentBO planContentBO = new PlanContentBO();
        planContentBO.setId(param.getId());
        planContentBO.setUserId(param.get_user().getUserId());
        planContentBO.setPlanId(param.getPlanId());
        planContentBO.setTitle(param.getTitle());
        planContentBO.setContent(param.getContent());
        if (param.getTravelSuggest() != null) {
            PlanContentBO.Suggest suggest = new PlanContentBO.Suggest();
            suggest.setTravelSuggest(param.getTravelSuggest().getTravelSuggest());
            suggest.setSightSuggest(param.getTravelSuggest().getSightSuggest());
            suggest.setDefectSuggest(param.getTravelSuggest().getDefectSuggest());
            suggest.setDisclose(param.getTravelSuggest().getDisclose());
            planContentBO.setTravelSuggest(suggest);
        }
        planContentBO.setScore(param.getScore());
        PlanContentBO.ExtraInfo extraInfo = new PlanContentBO.ExtraInfo();
        extraInfo.setMoneyCost(param.getMoneyCost());
        extraInfo.setTimeCost(param.getTimeCost());
        extraInfo.setImgList(param.getImgList());
        planContentBO.setExtraInfo(extraInfo);
        planContentBO.setPlanRelationId(param.getPlanRelationId());
        return planContentBO;
    }

    public static PlanContentInfoVO convertToPlanContentInfoVO(PlanContentBO planContentBO) {
        if (planContentBO == null) {
            return null;
        }
        PlanContentInfoVO planContentInfoVO = new PlanContentInfoVO();
        planContentInfoVO.setPlanId(String.valueOf(planContentBO.getPlanId()));
        planContentInfoVO.setScore(planContentBO.getScore());
        planContentInfoVO.setId(String.valueOf(planContentBO.getId()));
        planContentInfoVO.setTitle(planContentBO.getTitle());
        planContentInfoVO.setContent(planContentBO.getContent());
        if (planContentBO.getTravelSuggest() != null) {
            PlanContentInfoVO.Suggest suggest = new PlanContentInfoVO.Suggest();
            suggest.setTravelSuggest(planContentBO.getTravelSuggest().getTravelSuggest());
            suggest.setSightSuggest(planContentBO.getTravelSuggest().getSightSuggest());
            suggest.setDefectSuggest(planContentBO.getTravelSuggest().getDefectSuggest());
            suggest.setDisclose(planContentBO.getTravelSuggest().getDisclose());
            planContentInfoVO.setTravelSuggest(suggest);
        }
        if (planContentBO.getExtraInfo() != null) {
            planContentInfoVO.setMoneyCost(planContentBO.getExtraInfo().getMoneyCost());
            planContentInfoVO.setTimeCost(planContentBO.getExtraInfo().getTimeCost());
            planContentInfoVO.setImgList(planContentBO.getExtraInfo().getImgList());
        }
        planContentInfoVO.setPlanRelationId(planContentBO.getPlanRelationId());
        return planContentInfoVO;
    }


    public static StrategyInfoBO convertToStrategyInfoBO(InsertUserStrategyParam param) {
        if (param == null) {
            return null;
        }
        StrategyInfoBO request = new StrategyInfoBO();
        request.setTitle(param.getTitle());
        request.setPlanId(param.getPlanId());
        if (param.getGuide() != null) {
            StrategyInfoBO.TravelGuide guide = new StrategyInfoBO.TravelGuide();
            guide.setCityExp(param.getGuide().getCityExp());
            guide.setPlayExp(param.getGuide().getPlayExp());
            guide.setTravelExp(param.getGuide().getTravelExp());
            guide.setFoodExp(param.getGuide().getFoodExp());
            request.setGuide(guide);
        }
        if (param.getSuggest() != null) {
            StrategyInfoBO.Suggest suggest = new StrategyInfoBO.Suggest();
            suggest.setTravelSuggest(param.getSuggest().getTravelSuggest());
            suggest.setSecuritySuggest(param.getSuggest().getSecuritySuggest());
            suggest.setDefectSuggest(param.getSuggest().getDefectSuggest());
            suggest.setDisclose(param.getSuggest().getDisclose());
            request.setSuggest(suggest);
        }
        request.setIsAssociatePlanContent(param.getIsAssociatePlanContent());
        request.setAllowComment(AllowedCommentEnum.getByType(param.getAllowComment()));
        request.setIsPrivate(PrivateTypeEnum.getByType(param.getIsPrivate()));
        request.setUserId(param.get_user().getUserId());
        request.setMainImg(param.getMainImg());
        return request;
    }


    public static StrategyInfoBO convertToStrategyInfoBO(UpdateUserStrategyParam param) {
        if (param == null) {
            return null;
        }
        StrategyInfoBO request = new StrategyInfoBO();
        request.setTitle(param.getTitle());
        request.setPlanId(param.getPlanId());
        if (param.getGuide() != null) {
            StrategyInfoBO.TravelGuide guide = new StrategyInfoBO.TravelGuide();
            guide.setCityExp(param.getGuide().getCityExp());
            guide.setPlayExp(param.getGuide().getPlayExp());
            guide.setTravelExp(param.getGuide().getTravelExp());
            guide.setFoodExp(param.getGuide().getFoodExp());
            request.setGuide(guide);
        }
        if (param.getSuggest() != null) {
            StrategyInfoBO.Suggest suggest = new StrategyInfoBO.Suggest();
            suggest.setTravelSuggest(param.getSuggest().getTravelSuggest());
            suggest.setSecuritySuggest(param.getSuggest().getSecuritySuggest());
            suggest.setDefectSuggest(param.getSuggest().getDefectSuggest());
            suggest.setDisclose(param.getSuggest().getDisclose());
            request.setSuggest(suggest);
        }
        request.setIsAssociatePlanContent(param.getIsAssociatePlanContent());
        request.setAllowComment(AllowedCommentEnum.getByType(param.getAllowComment()));
        request.setIsPrivate(PrivateTypeEnum.getByType(param.getIsPrivate()));
        request.setId(param.getStrategyId());
        request.setUserId(param.get_user().getUserId());
        request.setMainImg(param.getMainImg());
        return request;
    }

    public static UserStrategyDetailVO buildUserStrategyDetailVO(StrategyDetailBO strategyDetailBO, Map<Long/*planRelationId*/, PlanContentBO> relationIdMap, BaseUserInfoResponse userInfoResponse) {
        if (userInfoResponse == null || strategyDetailBO == null) {
            return null;
        }
        UserStrategyDetailVO userStrategyDetailVO = new UserStrategyDetailVO();
        userStrategyDetailVO.setBaseUserVO(BuildBaseUserVO(userInfoResponse));
        userStrategyDetailVO.setStrategyId(userStrategyDetailVO.getStrategyId());
        userStrategyDetailVO.setPlanSetInfoVO(buildPagePlanSetBaseResponse(userInfoResponse, strategyDetailBO.getPlanSetBO()));
        userStrategyDetailVO.setBaseVO(convertToUserStrategyDetailVOBaseVO(strategyDetailBO.getStrategyInfoBO()));
        userStrategyDetailVO.setRelationVOList(buildUserStrategyDetailVORelationVO(strategyDetailBO, relationIdMap));
        return userStrategyDetailVO;
    }

    private static List<UserStrategyDetailVO.RelationVO> buildUserStrategyDetailVORelationVO(StrategyDetailBO strategyDetailBO, Map<Long/*planRelationId*/, PlanContentBO> relationIdMap) {
        if (strategyDetailBO == null || strategyDetailBO.getPlanRelationBOList() == null) {
            return Lists.newArrayList();
        }
        List<UserStrategyDetailVO.RelationVO> relationVOList = new ArrayList<>();
        List<PlanRelationBO> planRelationResponseList = strategyDetailBO.getPlanRelationBOList();
        for (PlanRelationBO planRelationResponse : planRelationResponseList) {
            UserStrategyDetailVO.RelationVO relationVO = new UserStrategyDetailVO.RelationVO();

            PlanRelationInfoVO planRelationInfoVO = convertToPlanRelationInfoVO(planRelationResponse);
            relationVO.setPlanRelationInfoVO(planRelationInfoVO);

            PlanContentVO planContentVO = new PlanContentVO();
            if (relationIdMap.containsKey(planRelationResponse.getId())) {
                PlanContentBO planContentBO = relationIdMap.get(planRelationResponse.getId());
                planContentVO.setContent(planContentBO.getContent());
                planContentVO.setId(String.valueOf(planContentBO.getId()));
                planContentVO.setPlanId(String.valueOf(planContentBO.getPlanId()));
                planContentVO.setPlanRelationId(planContentBO.getPlanRelationId());
                planContentVO.setTitle(planContentBO.getTitle());
                if (planContentBO.getExtraInfo() != null) {
                    PlanContentVO.ExtraInfo extraInfo = new PlanContentVO.ExtraInfo();
                    extraInfo.setTimeCost(planContentBO.getExtraInfo().getTimeCost());
                    extraInfo.setMoneyCost(planContentBO.getExtraInfo().getMoneyCost());
                    extraInfo.setImgList(planContentBO.getExtraInfo().getImgList());
                    planContentVO.setExtraInfo(extraInfo);
                }
                if (planContentBO.getTravelSuggest() != null) {
                    PlanContentVO.Suggest suggest = new PlanContentVO.Suggest();
                    suggest.setTravelSuggest(planContentBO.getTravelSuggest().getTravelSuggest());
                    suggest.setSightSuggest(planContentBO.getTravelSuggest().getSightSuggest());
                    suggest.setDisclose(planContentBO.getTravelSuggest().getDisclose());
                    suggest.setDefectSuggest(planContentBO.getTravelSuggest().getDefectSuggest());
                    planContentVO.setTravelSuggest(suggest);
                }
                planContentVO.setScore(planContentBO.getScore());
            }
            relationVO.setPlanContentVO(planContentVO);
            relationVOList.add(relationVO);
        }
        return relationVOList;
    }

    private static UserStrategyDetailVO.BaseVO convertToUserStrategyDetailVOBaseVO(StrategyInfoBO strategyInfoBO) {
        if (strategyInfoBO == null) {
            return null;
        }
        UserStrategyDetailVO.BaseVO baseVO = new UserStrategyDetailVO.BaseVO();
        baseVO.setPlanId(strategyInfoBO.getPlanId());
        baseVO.setTitle(strategyInfoBO.getTitle());
        baseVO.setMainImg(strategyInfoBO.getMainImg());
        baseVO.setStatus(strategyInfoBO.getStatus() == null ? null : strategyInfoBO.getStatus().getType());
        if (strategyInfoBO.getSuggest() != null) {
            UserStrategyDetailVO.Suggest suggest = new UserStrategyDetailVO.Suggest();
            suggest.setDefectSuggest(strategyInfoBO.getSuggest().getDefectSuggest());
            suggest.setDisclose(strategyInfoBO.getSuggest().getDisclose());
            suggest.setTravelSuggest(strategyInfoBO.getSuggest().getTravelSuggest());
            suggest.setSecuritySuggest(strategyInfoBO.getSuggest().getSecuritySuggest());
            baseVO.setSuggest(suggest);
        }
        if (strategyInfoBO.getGuide() != null) {
            UserStrategyDetailVO.TravelGuide guide = new UserStrategyDetailVO.TravelGuide();
            guide.setCityExp(strategyInfoBO.getGuide().getCityExp());
            guide.setFoodExp(strategyInfoBO.getGuide().getFoodExp());
            guide.setPlayExp(strategyInfoBO.getGuide().getPlayExp());
            guide.setTravelExp(strategyInfoBO.getGuide().getTravelExp());
            baseVO.setGuide(guide);
        }
        baseVO.setIsAssociatePlanContent(strategyInfoBO.getIsAssociatePlanContent());
        baseVO.setIsPrivate(strategyInfoBO.getIsPrivate());
        baseVO.setAllowComment(strategyInfoBO.getAllowComment() == null ? null : strategyInfoBO.getAllowComment().getType());
        return baseVO;
    }


    public static StrategyInfoConditionBO convertToStrategyInfoConditionBO(QueryUserStrategyByUserIdParam param) {
        if (param == null) {
            return null;
        }
        StrategyInfoConditionBO request = new StrategyInfoConditionBO();
        request.setPageIndex(param.getPageIndex());
        request.setPageSize(param.getPageSize());
        request.setPageIndex(param.getPageIndex());
        request.setUserId(param.get_user().getUserId());
        return request;
    }

    public static StrategyBaseVO buildStrategyBaseVO(StrategyInfoBO strategyInfoBO, PlanSetBO planSetBO, BaseUserInfoResponse userAccountResponse) {
        if (strategyInfoBO == null || planSetBO == null || userAccountResponse == null) {
            return null;
        }
        StrategyBaseVO strategyBaseVO = new StrategyBaseVO();
        strategyBaseVO.setBaseUserVO(BuildBaseUserVO(userAccountResponse));
        strategyBaseVO.setTitle(strategyInfoBO.getTitle());
        strategyBaseVO.setStrategyType(planSetBO.getPlanType() == null ? null : planSetBO.getPlanType().getType());
        strategyBaseVO.setTimeCost(planSetBO.getPlanUseTime());
        strategyBaseVO.setMoneyCost(planSetBO.getPlanMoneySpend());
        strategyBaseVO.setMainImg(strategyInfoBO.getMainImg());
        strategyBaseVO.setCity(planSetBO.getPlanCity());
        strategyBaseVO.setReferenceCount(strategyInfoBO.getReferenceCount());
        strategyBaseVO.setCollectCount(strategyInfoBO.getCollectCount());
        strategyBaseVO.setCommentCount(strategyInfoBO.getCommentCount());
        strategyBaseVO.setLikeCount(strategyInfoBO.getLikeCount());
        strategyBaseVO.setViewCount(strategyInfoBO.getViewCount());
        strategyBaseVO.setStrategyClassify(1);
        strategyBaseVO.setTravelMonth(convertToMonth(planSetBO.getStartPlanTime()));
        strategyBaseVO.setBizId(strategyInfoBO.getId());
        strategyBaseVO.setStrategyTypeStr(planSetBO.getPlanType() == null ? null : planSetBO.getPlanType().getName());
        strategyBaseVO.setTravelDays(DateUtils.differentDaysByMillisecond(planSetBO.getStartPlanTime(), planSetBO.getEndPlanTime()));
        return strategyBaseVO;
    }

    private static String convertToMonth(Date startPlanTime) {
        String dateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM, startPlanTime);
        int month = Integer.parseInt(dateStr.substring(5));
        switch (month) {
            case 1:
                return "一月";
            case 2:
                return "二月";
            case 3:
                return "三月";
            case 4:
                return "四月";
            case 5:
                return "五月";
            case 6:
                return "六月";
            case 7:
                return "七月";
            case 8:
                return "八月";
            case 9:
                return "九月";
            case 10:
                return "十月";
            case 11:
                return "十一月";
            case 12:
                return "十二月";
        }
        return "";
    }

    public static MemoTemplateDetailVO convertToMemoTemplateDetailVO(MemoTemplateBO response) {
        if (response == null) {
            return null;
        }
        MemoTemplateDetailVO detailVO = new MemoTemplateDetailVO();
        detailVO.setTemplateId(response.getId());
        detailVO.setName(response.getName());
        detailVO.setBaseType(response.getMemoTypeEnum() == null ? null : response.getMemoTypeEnum().getType());
        detailVO.setBaseTypeStr(response.getMemoTypeEnum() == null ? null : response.getMemoTypeEnum().getName());
        detailVO.setUseCount(response.getUseCount());
        detailVO.setCreateTime(response.getCreateTime());
        detailVO.setContentModel(convertToDetailVOContentModelParam(response.getContentModel()));
        detailVO.setSuggestStrategy(response.getSuggestStrategy() == null ? null : response.getSuggestStrategy().getType());
        detailVO.setSuggestStrategyStr(response.getSuggestStrategy() == null ? null : response.getSuggestStrategy().getName());
        detailVO.setReferenceOpinion(response.getReferenceOpinion());
        detailVO.setDesc(response.getDesc());
        return detailVO;
    }

    private static MemoTemplateContentModelParam convertToDetailVOContentModelParam(MemoTemplateContentModel contentModel) {
        if (contentModel == null) {
            return null;
        }
        MemoTemplateContentModelParam modelParam = new MemoTemplateContentModelParam();
        List<MemoTemplateContentModelParam.ModuleClassify> moduleClassifyParamList = new ArrayList<>();
        for (MemoTemplateContentModel.ModuleClassify moduleClassify : contentModel.getModuleClassifyList()) {
            MemoTemplateContentModelParam.ModuleClassify moduleClassifyParam = new MemoTemplateContentModelParam.ModuleClassify();
            moduleClassifyParam.setModuleName(moduleClassify.getModuleName());
            moduleClassifyParam.setSort(moduleClassify.getSort());

            List<MemoTemplateContentModelParam.Item> itemParamList = new ArrayList<>();
            for (MemoTemplateContentModel.Item item : moduleClassify.getItemList()) {
                MemoTemplateContentModelParam.Item itemParam = new MemoTemplateContentModelParam.Item();
                itemParam.setItemName(item.getItemName());
                itemParam.setDescribe(item.getDescribe());
                itemParam.setSort(item.getSort());
                itemParamList.add(itemParam);
            }
            itemParamList.sort(Comparator.comparing(MemoTemplateContentModelParam.Item::getSort));
            moduleClassifyParam.setItemList(itemParamList);
            moduleClassifyParamList.add(moduleClassifyParam);
        }
        moduleClassifyParamList.sort(Comparator.comparing(MemoTemplateContentModelParam.ModuleClassify::getSort));
        modelParam.setModuleClassifyList(moduleClassifyParamList);
        return modelParam;
    }

    public static List<MemoTemplateVO> convertToMemoTemplateVOList(List<MemoTemplateBO> memoTemplateBOList) {
        if (CollectionUtils.isEmpty(memoTemplateBOList)) {
            return Lists.newArrayList();
        }
        return memoTemplateBOList.stream().map(StrategyConvert::convertToMemoTemplateVO).collect(Collectors.toList());
    }

    public static MemoTemplateVO convertToMemoTemplateVO(MemoTemplateBO memoTemplateBO) {
        if (memoTemplateBO == null) {
            return null;
        }
        MemoTemplateVO memoTemplateVO = new MemoTemplateVO();
        memoTemplateVO.setTemplateId(memoTemplateBO.getId());
        memoTemplateVO.setName(memoTemplateBO.getName());
        memoTemplateVO.setDesc(memoTemplateBO.getDesc());
        memoTemplateVO.setSuggestStrategy(memoTemplateBO.getSuggestStrategy() == null ? null : memoTemplateBO.getSuggestStrategy().getType());
        memoTemplateVO.setSuggestStrategyStr(memoTemplateBO.getSuggestStrategy() == null ? null : memoTemplateBO.getSuggestStrategy().getName());
        memoTemplateVO.setUseCount(memoTemplateBO.getUseCount());
        memoTemplateVO.setCreateTime(memoTemplateBO.getCreateTime());
        if (memoTemplateBO.getContentModel() != null) {
            MemoTemplateContentModel contentModel = memoTemplateBO.getContentModel();
            memoTemplateVO.setModuleCount(contentModel.getModuleClassifyList().size());
            AtomicReference<Integer> sumItemCount = new AtomicReference<>(0);
            contentModel.getModuleClassifyList().forEach(item -> {
                int size = item.getItemList().size();
                sumItemCount.updateAndGet(v -> v + size);
            });
            memoTemplateVO.setItemCount(sumItemCount.get());
        }
        return memoTemplateVO;
    }

    public static MemoTemplateBO convertToMemoTemplateBO(InsertMemoTemplateParam param) {
        if (param == null || param.get_user() == null) {
            return null;
        }
        MemoTemplateBO request = new MemoTemplateBO();
        request.setName(param.getName());
        request.setDesc(param.getDesc());
        request.setSuggestStrategy(MemoSuggestStrategyEnum.getByType(param.getSuggestStrategy()));
        request.setReferenceOpinion(param.getReferenceOpinion());
        request.setContentModel(convertToMemoTemplateContentModel(param.getContentModel()));
        request.setUserId(param.get_user().getUserId());
        return request;
    }

    public static MemoTemplateBO convertToMemoTemplateBO(UpdateMemoTemplateParam param) {
        if (param == null || param.get_user() == null) {
            return null;
        }
        MemoTemplateBO request = new MemoTemplateBO();
        request.setName(param.getName());
        request.setDesc(param.getDesc());
        request.setSuggestStrategy(MemoSuggestStrategyEnum.getByType(param.getSuggestStrategy()));
        request.setReferenceOpinion(param.getReferenceOpinion());
        request.setContentModel(convertToMemoTemplateContentModel(param.getContentModel()));
        request.setId(param.getTemplateId());
        request.setUserId(param.get_user().getUserId());
        return request;
    }

    public static MemoTemplateBO buildMemoTemplateBO(MemoTemplateBO response, CopyMemoTemplateByIdParam param) {
        if (response == null || param == null || param.get_user() == null) {
            return null;
        }
        MemoTemplateBO request = new MemoTemplateBO();
        request.setName(response.getName());
        request.setDesc(response.getDesc());
        request.setSuggestStrategy(response.getSuggestStrategy());
        request.setReferenceOpinion(response.getReferenceOpinion());
        request.setContentModel(response.getContentModel());
        request.setUserId(param.get_user().getUserId());
        return request;
    }


    public static MemoUserRelationDetailVO convertToMemoUserRelationDetailVO(MemoUserRelationBO memoUserRelationBO) {
        if (memoUserRelationBO == null) {
            return null;
        }
        MemoUserRelationDetailVO detailVO = new MemoUserRelationDetailVO();
        detailVO.setMemoUserRelationId(memoUserRelationBO.getId());
        detailVO.setUserId(memoUserRelationBO.getUserId());
        detailVO.setPlanId(memoUserRelationBO.getPlanId());
        detailVO.setIsFinish(memoUserRelationBO.getIsFinish());
        detailVO.setContentModel(convertToRelationContentModelParam(memoUserRelationBO.getContent()));
        detailVO.setCreateTime(memoUserRelationBO.getCreateTime());
        detailVO.setRemark(memoUserRelationBO.getRemark());
        return detailVO;
    }


    private static MemoRelationContentModelParam convertToRelationContentModelParam(MemoUserRelationContentModel content) {
        if (content == null) {
            return null;
        }
        MemoRelationContentModelParam modelParam = new MemoRelationContentModelParam();
        List<MemoRelationContentModelParam.ModuleClassify> moduleClassifyParamList = new ArrayList<>();
        for (MemoUserRelationContentModel.ModuleClassify moduleClassify : content.getModuleClassifyList()) {
            MemoRelationContentModelParam.ModuleClassify moduleClassifyParam = new MemoRelationContentModelParam.ModuleClassify();
            moduleClassifyParam.setModuleName(moduleClassify.getModuleName());
            moduleClassifyParam.setSort(moduleClassify.getSort());

            List<MemoRelationContentModelParam.Item> itemParamList = new ArrayList<>();
            for (MemoUserRelationContentModel.Item item : moduleClassify.getItemList()) {
                MemoRelationContentModelParam.Item itemParam = new MemoRelationContentModelParam.Item();
                itemParam.setItemName(item.getItemName());
                itemParam.setDescribe(item.getDescribe());
                itemParam.setSort(item.getSort());
                itemParam.setChecked(item.getChecked());
                itemParam.setRemark(item.getRemark());
                itemParamList.add(itemParam);
            }
            itemParamList.sort(Comparator.comparing(MemoRelationContentModelParam.Item::getSort));
            moduleClassifyParam.setItemList(itemParamList);
            moduleClassifyParamList.add(moduleClassifyParam);
        }
        moduleClassifyParamList.sort(Comparator.comparing(MemoRelationContentModelParam.ModuleClassify::getSort));
        modelParam.setModuleClassifyList(moduleClassifyParamList);
        return modelParam;
    }

    public static MemoUserRelationBO convertToMemoUserRelationBO(UpdateMemoUserRelationByIdParam param) {
        if (param == null || param.get_user() == null) {
            return null;
        }
        MemoUserRelationBO request = new MemoUserRelationBO();
        request.setId(param.getMemoUserRelationId());
        request.setContent(convertToMemoUserRelationContentModel(param.getContentModel()));
        request.setIsFinish(param.getIsFinish());
        request.setUserId(param.get_user().getUserId());
        request.setRemark(param.get_user().getUserName());
        return request;
    }


    public static MemoUserRelationBO buildInsertMemoUserRelationByTemplate(MemoTemplateBO response, BuildMemoUserRelationByTemplateParam param) {
        if (response == null || param == null || param.get_user() == null) {
            return null;
        }
        MemoUserRelationBO request = new MemoUserRelationBO();
        request.setId(TodoCommonUtils.buildLongGuid());
        request.setPlanId(param.getPlanId());
        request.setUserId(param.get_user().getUserId());

        MemoUserRelationContentModel modelParam = new MemoUserRelationContentModel();
        if (response.getContentModel() != null) {
            MemoTemplateContentModel contentModel = response.getContentModel();
            List<MemoUserRelationContentModel.ModuleClassify> moduleClassifyParamList = new ArrayList<>();
            for (MemoTemplateContentModel.ModuleClassify moduleClassify : contentModel.getModuleClassifyList()) {
                MemoUserRelationContentModel.ModuleClassify moduleClassifyParam = new MemoUserRelationContentModel.ModuleClassify();
                moduleClassifyParam.setModuleName(moduleClassify.getModuleName());
                moduleClassifyParam.setSort(moduleClassify.getSort());

                List<MemoUserRelationContentModel.Item> itemParamList = new ArrayList<>();
                for (MemoTemplateContentModel.Item item : moduleClassify.getItemList()) {
                    MemoUserRelationContentModel.Item itemParam = new MemoUserRelationContentModel.Item();
                    itemParam.setItemName(item.getItemName());
                    itemParam.setDescribe(item.getDescribe());
                    itemParam.setSort(item.getSort());
                    itemParam.setChecked(0);
                    itemParam.setRemark("");
                    itemParamList.add(itemParam);
                }
                itemParamList.sort(Comparator.comparing(MemoUserRelationContentModel.Item::getSort));
                moduleClassifyParam.setItemList(itemParamList);
                moduleClassifyParamList.add(moduleClassifyParam);
            }
            moduleClassifyParamList.sort(Comparator.comparing(MemoUserRelationContentModel.ModuleClassify::getSort));
            modelParam.setModuleClassifyList(moduleClassifyParamList);
        }

        request.setContent(modelParam);
        request.setRemark("默认备注：请记得及时购买往返车票以及出行期间的门票等，出行期间注意安全，【途度攻略】预祝您路途愉快。");
        request.setIsFinish(0);
        return request;
    }


    private static MemoTemplateContentModel convertToMemoTemplateContentModel(MemoTemplateContentModelParam contentModel) {

        if (contentModel == null) {
            return null;
        }
        MemoTemplateContentModel modelParam = new MemoTemplateContentModel();
        List<MemoTemplateContentModel.ModuleClassify> moduleClassifyParamList = new ArrayList<>();
        for (MemoTemplateContentModelParam.ModuleClassify moduleClassify : contentModel.getModuleClassifyList()) {
            MemoTemplateContentModel.ModuleClassify moduleClassifyParam = new MemoTemplateContentModel.ModuleClassify();
            moduleClassifyParam.setModuleName(moduleClassify.getModuleName());
            moduleClassifyParam.setSort(moduleClassify.getSort());

            List<MemoTemplateContentModel.Item> itemParamList = new ArrayList<>();
            for (MemoTemplateContentModelParam.Item item : moduleClassify.getItemList()) {
                MemoTemplateContentModel.Item itemParam = new MemoTemplateContentModel.Item();
                itemParam.setItemName(item.getItemName());
                itemParam.setDescribe(item.getDescribe());
                itemParam.setSort(item.getSort());
                itemParamList.add(itemParam);
            }
            itemParamList.sort(Comparator.comparing(MemoTemplateContentModel.Item::getSort));
            moduleClassifyParam.setItemList(itemParamList);
            moduleClassifyParamList.add(moduleClassifyParam);
        }
        moduleClassifyParamList.sort(Comparator.comparing(MemoTemplateContentModel.ModuleClassify::getSort));
        modelParam.setModuleClassifyList(moduleClassifyParamList);
        return modelParam;
    }


    private static MemoUserRelationContentModel convertToMemoUserRelationContentModel(MemoRelationContentModelParam contentModel) {
        if (contentModel == null) {
            return null;
        }
        MemoUserRelationContentModel modelParam = new MemoUserRelationContentModel();
        List<MemoUserRelationContentModel.ModuleClassify> moduleClassifyParamList = new ArrayList<>();
        for (MemoRelationContentModelParam.ModuleClassify moduleClassify : contentModel.getModuleClassifyList()) {
            MemoUserRelationContentModel.ModuleClassify moduleClassifyParam = new MemoUserRelationContentModel.ModuleClassify();
            moduleClassifyParam.setModuleName(moduleClassify.getModuleName());
            moduleClassifyParam.setSort(moduleClassify.getSort());

            List<MemoUserRelationContentModel.Item> itemParamList = new ArrayList<>();
            for (MemoRelationContentModelParam.Item item : moduleClassify.getItemList()) {
                MemoUserRelationContentModel.Item itemParam = new MemoUserRelationContentModel.Item();
                itemParam.setItemName(item.getItemName());
                itemParam.setDescribe(item.getDescribe());
                itemParam.setSort(item.getSort());
                itemParam.setChecked(item.getChecked());
                itemParam.setRemark(item.getRemark());
                itemParamList.add(itemParam);
            }
            itemParamList.sort(Comparator.comparing(MemoUserRelationContentModel.Item::getSort));
            moduleClassifyParam.setItemList(itemParamList);
            moduleClassifyParamList.add(moduleClassifyParam);
        }
        moduleClassifyParamList.sort(Comparator.comparing(MemoUserRelationContentModel.ModuleClassify::getSort));
        modelParam.setModuleClassifyList(moduleClassifyParamList);
        return modelParam;
    }


    public static StrategySearchBO convertToStrategySearchBO(SearchStrategyParam param) {
        if (param == null) {
            return null;
        }
        StrategySearchBO request = new StrategySearchBO();
        request.setPageIndex(param.getPageIndex());
        request.setPageSize(param.getPageSize());
        request.setKeyword(param.getKeyword());
        request.setProvince(param.getProvince());
        request.setCity(param.getCity());
        request.setCurrentIndex(param.getCurrentIndex());
        return request;
    }

    public static StrategySearchBO convertToStrategySearchBO(SearchPlatformStrategyParam param) {
        if (param == null) {
            return null;
        }
        StrategySearchBO request = new StrategySearchBO();
        request.setPageIndex(param.getPageIndex());
        request.setPageSize(param.getPageSize());
        request.setKeyword(param.getKeyword());
        request.setProvince(param.getProvince());
        request.setCity(param.getCity());
        request.setCurrentIndex(param.getCurrentIndex());
        request.setIsPlatform(1);
        return request;
    }

    public static PageResult<StrategyBaseVO> convertToStrategyBaseVOPageResult(PageResult<BasicStrategyBO> pageResult) {
        if (pageResult == null) {
            return PageResult.of(Lists.newArrayList(), 0, 0, 0);
        }
        if (CollectionUtils.isEmpty(pageResult.getResults())) {
            return PageResult.of(Lists.newArrayList(), pageResult.getPageNum(), pageResult.getPageSize(), pageResult.getTotal());
        }
        PageResult<StrategyBaseVO> result = new PageResult<>();
        result.setPageNum(pageResult.getPageNum());
        result.setPageSize(pageResult.getPageSize());
        result.setTotal(pageResult.getTotal());
        result.setResults(pageResult.getResults().stream().map(StrategyConvert::convertToStrategyBaseVO).collect(Collectors.toList()));
        result.setHasNext(pageResult.isHasNext());
        result.setCurrentIndex(pageResult.getCurrentIndex());
        result.setPageCount(pageResult.getPageCount());
        return result;
    }

    public static StrategyBaseVO convertToStrategyBaseVO(BasicStrategyBO response) {
        if (response == null) {
            return null;
        }
        StrategyBaseVO strategyBaseVO = new StrategyBaseVO();
        strategyBaseVO.setTitle(response.getTitle());
        strategyBaseVO.setStrategyType(response.getStrategyType() == null ? null : response.getStrategyType().getType());
        strategyBaseVO.setTimeCost(response.getTimeCost());
        strategyBaseVO.setMoneyCost(response.getMoneyCost());
        strategyBaseVO.setMainImg(response.getMainImg());
        strategyBaseVO.setScore(response.getScore());
        strategyBaseVO.setRecommendDesc(response.getRecommendDesc());
        strategyBaseVO.setProvince(response.getProvince());
        strategyBaseVO.setCity(response.getCity());
        strategyBaseVO.setReferenceCount(response.getReferenceCount());
        strategyBaseVO.setCollectCount(response.getCollectCount());
        strategyBaseVO.setCommentCount(response.getCommentCount());
        strategyBaseVO.setLikeCount(response.getLikeCount());
        strategyBaseVO.setViewCount(response.getViewCount());
        strategyBaseVO.setStrategyClassify(0);
        strategyBaseVO.setBizId(response.getId());
        strategyBaseVO.setStrategyTypeStr(response.getStrategyType().getName());
        strategyBaseVO.setStrategyClassify(response.getIsPlatform());
        strategyBaseVO.setTravelDays(response.getTravelTimeType() == null ? 0 : response.getTravelTimeType().getDays());
        return strategyBaseVO;
    }

    public static PlanSetPO convertToPlanSetPO(PlanSetBO planSetBO) {
        if (planSetBO == null) {
            return null;
        }
        PlanSetPO planSetPO = new PlanSetPO();
        planSetPO.setId(planSetBO.getPlanId() == null ? TodoCommonUtils.buildLongGuid() : planSetBO.getPlanId());
        planSetPO.setUserId(planSetBO.getUserId());
        planSetPO.setPlanUseTime(planSetBO.getPlanUseTime());
        planSetPO.setPlanMoneySpend(planSetBO.getPlanMoneySpend());
        planSetPO.setPlanType(planSetBO.getPlanType().getType());
        planSetPO.setPlanCity(planSetBO.getPlanCity());
        planSetPO.setEndPlanTime(planSetBO.getEndPlanTime());
        planSetPO.setStartPlanTime(planSetBO.getStartPlanTime());
        planSetPO.setDesc(planSetBO.getDesc());
        planSetPO.setStatus(planSetBO.getStatus() == null ? StrategyStatusEnum.PUBLISHED.getType() : planSetBO.getStatus().getType());
        planSetPO.setExtra(JSONObject.toJSONString(planSetBO.getExtra()));
        planSetPO.setIsPrivate(planSetBO.getIsPrivate().getType());
        planSetPO.setIsTravel(planSetBO.getIsTravel());
        planSetPO.setMainImg(planSetBO.getMainImg());
        planSetPO.setTitle(planSetBO.getTitle());
        planSetPO.setRelationCount(planSetBO.getRelationCount() == null ? 0 : planSetBO.getRelationCount());
        planSetPO.setIsDelete(0);
        planSetPO.setCreateTime(new Date());
        planSetPO.setUpdateTime(new Date());
        return planSetPO;
    }

    public static PlanSetBO convertToPlanSetBO(PlanSetPO planSetPO) {
        if (planSetPO == null) {
            return null;
        }
        PlanSetBO planSetBO = new PlanSetBO();
        planSetBO.setPlanId(planSetPO.getId());
        planSetBO.setUserId(planSetPO.getUserId());
        planSetBO.setPlanUseTime(planSetPO.getPlanUseTime());
        planSetBO.setPlanMoneySpend(planSetPO.getPlanMoneySpend());
        planSetBO.setPlanType(StrategyTypeEnum.getByType(planSetPO.getPlanType()));
        planSetBO.setPlanCity(planSetPO.getPlanCity());
        planSetBO.setEndPlanTime(planSetPO.getEndPlanTime());
        planSetBO.setStartPlanTime(planSetPO.getStartPlanTime());
        planSetBO.setDesc(planSetPO.getDesc());
        planSetBO.setStatus(planSetPO.getStatus() == null ? StrategyStatusEnum.PUBLISHED : StrategyStatusEnum.getByType(planSetPO.getStatus()));
        planSetBO.setExtra(JSONObject.parseObject(planSetPO.getExtra(), PlanSetBO.Extra.class));
        planSetBO.setIsPrivate(PrivateTypeEnum.getByType(planSetPO.getIsPrivate()));
        planSetBO.setIsTravel(planSetPO.getIsTravel());
        planSetBO.setMainImg(planSetPO.getMainImg());
        planSetBO.setTitle(planSetPO.getTitle());
        planSetBO.setRelationCount(planSetPO.getRelationCount());
        planSetBO.setTravelStatus(calTravelStatus(planSetPO.getStartPlanTime(), planSetPO.getEndPlanTime()));
        return planSetBO;
    }

    /**
     * 计算 出行状态 0-未开始 1-进行中 2-已完成
     *
     * @param startPlanTime
     * @param endPlanTime
     * @return
     */
    private static Integer calTravelStatus(Date startPlanTime, Date endPlanTime) {
        Date now = new Date();
        if (now.before(startPlanTime)) {
            return 0;
        }
        if (now.after(endPlanTime)) {
            return 2;
        }
        return 1;
    }

    public static PlanSetCondition convertToPlanSetCondition(PlanSetConditionBO planSetConditionBO) {
        if (planSetConditionBO == null) {
            return null;
        }
        PlanSetCondition planSetCondition = new PlanSetCondition();
        planSetCondition.setPlanType((planSetConditionBO.getPlanType() == null ? null : planSetConditionBO.getPlanType().getType()));
        planSetCondition.setPageIndex(planSetConditionBO.getPageIndex());
        planSetCondition.setPageSize(planSetConditionBO.getPageSize());
        planSetCondition.setCurrentIndex(planSetConditionBO.getCurrentIndex());
        planSetCondition.setStatus(planSetConditionBO.getStatus());
        planSetCondition.setStartPlanTime(planSetConditionBO.getStartPlanTime());
        planSetCondition.setEndPlanTime(planSetConditionBO.getEndPlanTime());
        planSetCondition.setTitle(planSetConditionBO.getTitle());
        planSetCondition.setPlanCity(planSetConditionBO.getPlanCity());
        planSetCondition.setUserId(planSetConditionBO.getUserId());
        planSetCondition.setPlanId(planSetConditionBO.getPlanId());
        return planSetCondition;
    }

    public static PlanRelationPO convertToPlanRelationPO(PlanRelationBO planRelationBO) {
        if (planRelationBO == null) {
            return null;
        }
        PlanRelationPO planRelationPO = new PlanRelationPO();
        planRelationPO.setId(planRelationBO.getId() == null ? TodoCommonUtils.buildLongGuid() : planRelationBO.getId());
        planRelationPO.setExtra(JSONObject.toJSONString(planRelationBO.getExtra()));
        planRelationPO.setRelationId(planRelationBO.getRelationId());
        planRelationPO.setBusinessId(planRelationBO.getBusinessId());
        planRelationPO.setBusinessScene(planRelationBO.getBusinessScene().getType());
        planRelationPO.setRelationType(planRelationBO.getRelationType().getType());
        planRelationPO.setPlanDay(planRelationBO.getPlanDay());
        planRelationPO.setMoneyCost(planRelationBO.getMoneyCost());
        planRelationPO.setSuggest(JSONObject.toJSONString(planRelationBO.getSuggest()));
        planRelationPO.setTimeCost(planRelationBO.getTimeCost());
        planRelationPO.setTitle(planRelationBO.getTitle());
        planRelationPO.setIsTravel(planRelationBO.getIsTravel() ? 0 : 1);
        planRelationPO.setRelationName(planRelationBO.getRelationName());
        planRelationPO.setStartTime(planRelationBO.getStartTime());
        planRelationPO.setRemark(planRelationBO.getRemark());
        planRelationPO.setIsDelete(0);
        planRelationPO.setCreateTime(new Date());
        planRelationPO.setUpdateTime(new Date());
        return planRelationPO;
    }

    public static PlanRelationBO convertToPlanRelationBO(PlanRelationPO planRelationPO) {
        if (planRelationPO == null) {
            return null;
        }
        PlanRelationBO planRelationBO = new PlanRelationBO();
        planRelationBO.setId(planRelationPO.getId());
        planRelationBO.setExtra(JSONObject.parseObject(planRelationPO.getExtra(), PlanRelationBO.Extra.class));
        planRelationBO.setRelationId(planRelationPO.getRelationId());
        planRelationBO.setBusinessId(planRelationPO.getBusinessId());
        planRelationBO.setBusinessScene(PlanRelationSceneEnum.getByType(planRelationPO.getBusinessScene()));
        planRelationBO.setRelationType(StrategyRelationTypeEnum.getByType(planRelationPO.getRelationType()));
        planRelationBO.setPlanDay(planRelationPO.getPlanDay());
        planRelationBO.setMoneyCost(planRelationPO.getMoneyCost());
        planRelationBO.setSuggest(JSONObject.parseObject(planRelationPO.getSuggest(), PlanRelationBO.Suggest.class));
        planRelationBO.setTimeCost(planRelationPO.getTimeCost());
        planRelationBO.setTitle(planRelationPO.getTitle());
        planRelationBO.setIsTravel(planRelationPO.getIsTravel() == 0);
        planRelationBO.setRelationName(planRelationPO.getRelationName());
        planRelationBO.setStartTime(planRelationPO.getStartTime());
        planRelationBO.setRemark(planRelationPO.getRemark());
        return planRelationBO;

    }

    public static TravelFriendRelationPO convertToTravelFriendRelationPO(TravelFriendRelationBO travelFriendRelationBO) {
        if (travelFriendRelationBO == null) {
            return null;
        }
        TravelFriendRelationPO travelFriendRelationPO = new TravelFriendRelationPO();
        travelFriendRelationPO.setId(travelFriendRelationBO.getId());
        travelFriendRelationPO.setExtra(JSONObject.toJSONString(travelFriendRelationBO.getExtra()));
        travelFriendRelationPO.setConfirm(travelFriendRelationBO.getConfirm());
        travelFriendRelationPO.setComment(travelFriendRelationBO.getComment());
        travelFriendRelationPO.setFriendId(travelFriendRelationBO.getFriendId());
        travelFriendRelationPO.setPlanId(travelFriendRelationBO.getPlanId());
        travelFriendRelationPO.setStrategyId(travelFriendRelationBO.getStrategyId());
        travelFriendRelationPO.setUserId(travelFriendRelationBO.getUserId());
        travelFriendRelationPO.setIsShow(travelFriendRelationBO.getIsShow());
        return travelFriendRelationPO;
    }

    public static TravelFriendRelationBO convertToTravelFriendRelationBO(TravelFriendRelationPO travelFriendRelationPO) {
        if (travelFriendRelationPO == null) {
            return null;
        }
        TravelFriendRelationBO travelFriendRelationBO = new TravelFriendRelationBO();
        travelFriendRelationBO.setId(travelFriendRelationPO.getId());
        travelFriendRelationBO.setExtra(JSONObject.parseObject(travelFriendRelationPO.getExtra(), TravelFriendRelationBO.Extra.class));
        travelFriendRelationBO.setConfirm(travelFriendRelationPO.getConfirm());
        travelFriendRelationBO.setComment(travelFriendRelationPO.getComment());
        travelFriendRelationBO.setFriendId(travelFriendRelationPO.getFriendId());
        travelFriendRelationBO.setPlanId(travelFriendRelationPO.getPlanId());
        travelFriendRelationBO.setStrategyId(travelFriendRelationPO.getStrategyId());
        travelFriendRelationBO.setUserId(travelFriendRelationPO.getUserId());
        travelFriendRelationBO.setIsShow(travelFriendRelationPO.getIsShow());
        return travelFriendRelationBO;
    }


    public static StrategyInfoPO convertToStrategyInfoPO(StrategyInfoBO strategyInfoBO) {
        if (strategyInfoBO == null) {
            return null;
        }
        StrategyInfoPO strategyInfoPO = new StrategyInfoPO();
        strategyInfoPO.setId(strategyInfoBO.getId() == null ? TodoCommonUtils.buildLongGuid() : strategyInfoBO.getId());
        strategyInfoPO.setExtra(JSONObject.toJSONString(strategyInfoBO.getExtra()));
        strategyInfoPO.setIsAssociatePlanContent(strategyInfoBO.getIsAssociatePlanContent());
        strategyInfoPO.setIsPrivate(strategyInfoBO.getIsPrivate().getType());
        strategyInfoPO.setMainImg(strategyInfoBO.getMainImg());
        strategyInfoPO.setPlanId(strategyInfoBO.getPlanId());
        strategyInfoPO.setPlanId(strategyInfoBO.getPlanId());
        strategyInfoPO.setSource(strategyInfoBO.getSource().getType());
        strategyInfoPO.setStatus(strategyInfoBO.getStatus() == null ? StrategyStatusEnum.DRAFT.getType() : strategyInfoBO.getStatus().getType());
        strategyInfoPO.setTitle(strategyInfoBO.getTitle());
        strategyInfoPO.setUserId(strategyInfoBO.getUserId());
        strategyInfoPO.setReferenceCount(strategyInfoBO.getReferenceCount());
        strategyInfoPO.setViewCount(strategyInfoBO.getViewCount());
        strategyInfoPO.setCollectCount(strategyInfoBO.getCollectCount());
        strategyInfoPO.setLikeCount(strategyInfoBO.getLikeCount());
        strategyInfoPO.setCommentCount(strategyInfoBO.getCommentCount());
        strategyInfoPO.setAllowComment(strategyInfoBO.getAllowComment().getType());
        strategyInfoPO.setSuggest(JSONObject.toJSONString(strategyInfoBO.getSuggest()));
        strategyInfoPO.setGuide(JSONObject.toJSONString(strategyInfoBO.getGuide()));
        strategyInfoPO.setIsDelete(0);
        strategyInfoPO.setCreateTime(new Date());
        strategyInfoPO.setUpdateTime(new Date());
        return strategyInfoPO;
    }

    public static StrategyInfoBO convertToStrategyInfoBO(StrategyInfoPO strategyInfoPO) {
        if (strategyInfoPO == null) {
            return null;
        }
        StrategyInfoBO strategyInfoBO = new StrategyInfoBO();
        strategyInfoBO.setExtra(JSONObject.parseObject(strategyInfoPO.getExtra(), StrategyInfoBO.Extra.class));
        strategyInfoBO.setId(strategyInfoPO.getId());
        strategyInfoBO.setIsAssociatePlanContent(strategyInfoPO.getIsAssociatePlanContent());
        strategyInfoBO.setIsPrivate(PrivateTypeEnum.getByType(strategyInfoPO.getIsPrivate()));
        strategyInfoBO.setMainImg(strategyInfoPO.getMainImg());
        strategyInfoBO.setTitle(strategyInfoPO.getTitle());
        strategyInfoBO.setPlanId(strategyInfoPO.getPlanId());
        strategyInfoBO.setSource(SourceEnum.getByType(strategyInfoPO.getSource()));
        strategyInfoBO.setStatus(StrategyStatusEnum.getByType(strategyInfoPO.getStatus()));
        strategyInfoBO.setUserId(strategyInfoPO.getUserId());
        strategyInfoBO.setReferenceCount(strategyInfoPO.getReferenceCount());
        strategyInfoBO.setViewCount(strategyInfoPO.getViewCount());
        strategyInfoBO.setCollectCount(strategyInfoPO.getCollectCount());
        strategyInfoBO.setLikeCount(strategyInfoPO.getLikeCount());
        strategyInfoBO.setCommentCount(strategyInfoPO.getCommentCount());
        strategyInfoBO.setAllowComment(AllowedCommentEnum.getByType(strategyInfoPO.getAllowComment()));
        strategyInfoBO.setSuggest(JSONObject.parseObject(strategyInfoPO.getSuggest(), StrategyInfoBO.Suggest.class));
        strategyInfoBO.setGuide(JSONObject.parseObject(strategyInfoPO.getGuide(), StrategyInfoBO.TravelGuide.class));
        return strategyInfoBO;
    }

    public static StrategyInfoCondition convertToStrategyInfoCondition(StrategyInfoConditionBO strategyInfoCondition) {
        if (strategyInfoCondition == null) {
            return null;
        }
        StrategyInfoCondition condition = new StrategyInfoCondition();
        condition.setPlanId(strategyInfoCondition.getPlanId());
        condition.setCurrentIndex(strategyInfoCondition.getCurrentIndex());
        condition.setStatus(strategyInfoCondition.getStatus() == null ? null : strategyInfoCondition.getStatus().getType());
        condition.setSource(strategyInfoCondition.getSource() == null ? null : strategyInfoCondition.getSource().getType());
        condition.setPageIndex(strategyInfoCondition.getPageIndex());
        condition.setPageSize(strategyInfoCondition.getPageSize());
        condition.setTitle(strategyInfoCondition.getTitle());
        condition.setUserId(strategyInfoCondition.getUserId());
        condition.setPageSize(strategyInfoCondition.getPageSize());
        return condition;
    }

    public static PlanContentPO convertToPlanContentPO(PlanContentBO planContentBO) {
        if (planContentBO == null) {
            return null;
        }
        PlanContentPO planContentPO = new PlanContentPO();
        planContentPO.setId(planContentBO.getId() == null ? TodoCommonUtils.buildLongGuid() : planContentBO.getId());
        planContentPO.setContent(planContentBO.getContent());
        planContentPO.setExtraInfo(JSONObject.toJSONString(planContentBO.getExtraInfo()));
        planContentPO.setPlanId(planContentBO.getPlanId());
        planContentPO.setPlanRelationId(planContentBO.getPlanRelationId());
        planContentPO.setScore(planContentBO.getScore());
        planContentPO.setTitle(planContentBO.getTitle());
        planContentPO.setTravelSuggest(JSONObject.toJSONString(planContentBO.getTravelSuggest()));
        planContentPO.setUserId(planContentBO.getUserId());
        planContentPO.setIsDelete(0);
        planContentPO.setCreateTime(new Date());
        planContentPO.setUpdateTime(new Date());
        return planContentPO;
    }

    public static PlanContentBO convertToPlanContentBO(PlanContentPO planContentPO) {
        if (planContentPO == null) {
            return null;
        }
        PlanContentBO planContentBO = new PlanContentBO();
        planContentBO.setContent(planContentPO.getContent());
        planContentBO.setExtraInfo(JSONObject.parseObject(planContentPO.getExtraInfo(), PlanContentBO.ExtraInfo.class));
        planContentBO.setId(planContentPO.getId());
        planContentBO.setPlanId(planContentPO.getPlanId());
        planContentBO.setPlanRelationId(planContentPO.getPlanRelationId());
        planContentBO.setScore(planContentPO.getScore());
        planContentBO.setTitle(planContentPO.getTitle());
        planContentBO.setTravelSuggest(JSONObject.parseObject(planContentPO.getTravelSuggest(), PlanContentBO.Suggest.class));
        planContentBO.setUserId(planContentPO.getUserId());
        return planContentBO;
    }

    public static PlatformStrategyPO convertToPlatformStrategyPO(PlatformStrategyBO platformStrategyBO) {
        if (platformStrategyBO == null) {
            return null;
        }
        PlatformStrategyPO platformStrategyPO = new PlatformStrategyPO();
        platformStrategyPO.setAllowComment(platformStrategyBO.getAllowComment().getType());
        platformStrategyPO.setCity(platformStrategyBO.getCity());
        platformStrategyPO.setReferenceCount(platformStrategyBO.getReferenceCount());
        platformStrategyPO.setCreateUser(platformStrategyBO.getCreateUser());
        platformStrategyPO.setScore(platformStrategyBO.getScore());
        platformStrategyPO.setProvince(platformStrategyBO.getProvince());
        platformStrategyPO.setStatus(platformStrategyBO.getStatus().getType());
        platformStrategyPO.setStrategyType(platformStrategyBO.getStrategyType().getType());
        platformStrategyPO.setTimeCost(platformStrategyBO.getTimeCost());
        platformStrategyPO.setTravelTimeType(platformStrategyBO.getTravelTimeType().getType());
        platformStrategyPO.setMoneyCost(platformStrategyBO.getMoneyCost());
        platformStrategyPO.setTitle(platformStrategyBO.getTitle());
        platformStrategyPO.setMainImg(platformStrategyBO.getMainImg());
        platformStrategyPO.setIsFree(platformStrategyBO.getIsFree());
        platformStrategyPO.setViewCount(platformStrategyBO.getViewCount());
        platformStrategyPO.setCollectCount(platformStrategyBO.getCollectCount());
        platformStrategyPO.setLikeCount(platformStrategyBO.getLikeCount());
        platformStrategyPO.setCommentCount(platformStrategyBO.getCommentCount());
        platformStrategyPO.setRecommendDesc(platformStrategyBO.getRecommendDesc());
        platformStrategyPO.setRecommendMonth(JSONObject.toJSONString(platformStrategyBO.getRecommendMonth()));
        platformStrategyPO.setLastUpdateUser(platformStrategyBO.getLastUpdateUser());
        platformStrategyPO.setId(platformStrategyBO.getStrategyId() == null ? TodoCommonUtils.buildLongGuid() : platformStrategyBO.getStrategyId());
        platformStrategyPO.setIsDelete(platformStrategyPO.getIsDelete() == null ? 0 : platformStrategyPO.getIsDelete());
        platformStrategyPO.setCreateTime(new Date());
        platformStrategyPO.setUpdateTime(new Date());
        return platformStrategyPO;
    }

    public static PlatformStrategyDetailPO convertToPlatformStrategyDetailPO(PlatformStrategyExtendBO platformStrategyExtendBO) {
        if (platformStrategyExtendBO == null) {
            return null;
        }
        PlatformStrategyDetailPO platformStrategyDetailPO = new PlatformStrategyDetailPO();
        platformStrategyDetailPO.setAgeSuggest(JSONObject.toJSONString(platformStrategyExtendBO.getAgeSuggest()));
        platformStrategyDetailPO.setExtra(JSONObject.toJSONString(platformStrategyExtendBO.getExtra()));
        platformStrategyDetailPO.setInstructions(JSONObject.toJSONString(platformStrategyExtendBO.getInstructions()));
        platformStrategyDetailPO.setSecuritySuggest(JSONObject.toJSONString(platformStrategyExtendBO.getSecuritySuggest()));
        platformStrategyDetailPO.setId(platformStrategyExtendBO.getStrategyId());
        platformStrategyDetailPO.setTravelSuggest(JSONObject.toJSONString(platformStrategyExtendBO.getTravelSuggest()));
        platformStrategyDetailPO.setIsDelete(0);
        platformStrategyDetailPO.setCreateTime(new Date());
        platformStrategyDetailPO.setUpdateTime(new Date());
        return platformStrategyDetailPO;
    }

    public static PlatformStrategyBO convertToPlatformStrategyBO(PlatformStrategyPO platformStrategyPO) {
        if (platformStrategyPO == null) {
            return null;
        }
        PlatformStrategyBO platformStrategyBO = new PlatformStrategyBO();
        platformStrategyBO.setAllowComment(AllowedCommentEnum.getByType(platformStrategyPO.getAllowComment()));
        platformStrategyBO.setCity(platformStrategyPO.getCity());
        platformStrategyBO.setReferenceCount(platformStrategyPO.getReferenceCount());
        platformStrategyBO.setCreateUser(platformStrategyPO.getCreateUser());
        platformStrategyBO.setScore(platformStrategyPO.getScore());
        platformStrategyBO.setProvince(platformStrategyPO.getProvince());
        platformStrategyBO.setStatus(StrategyStatusEnum.getByType(platformStrategyPO.getStatus()));
        platformStrategyBO.setStrategyType(StrategyTypeEnum.getByType(platformStrategyPO.getStrategyType()));
        platformStrategyBO.setTimeCost(platformStrategyPO.getTimeCost());
        platformStrategyBO.setTravelTimeType(TravelDayTypeEnum.getByType(platformStrategyPO.getTravelTimeType()));
        platformStrategyBO.setMoneyCost(platformStrategyPO.getMoneyCost());
        platformStrategyBO.setTitle(platformStrategyPO.getTitle());
        platformStrategyBO.setMainImg(platformStrategyPO.getMainImg());
        platformStrategyBO.setIsFree(platformStrategyPO.getIsFree());
        platformStrategyBO.setViewCount(platformStrategyPO.getViewCount());
        platformStrategyBO.setCollectCount(platformStrategyPO.getCollectCount());
        platformStrategyBO.setLikeCount(platformStrategyPO.getLikeCount());
        platformStrategyBO.setCommentCount(platformStrategyPO.getCommentCount());
        platformStrategyBO.setRecommendDesc(platformStrategyPO.getRecommendDesc());
        platformStrategyBO.setRecommendMonth(JSONObject.parseArray(platformStrategyPO.getRecommendMonth(), String.class));
        platformStrategyBO.setLastUpdateUser(platformStrategyPO.getLastUpdateUser());
        platformStrategyBO.setStrategyId(platformStrategyPO.getId());
        return platformStrategyBO;
    }

    public static PlatformStrategyExtendBO convertToPlatformStrategyExtendBO(PlatformStrategyDetailPO platformStrategyDetailPO) {
        if (platformStrategyDetailPO == null) {
            return null;
        }
        PlatformStrategyExtendBO platformStrategyExtendBO = new PlatformStrategyExtendBO();
        platformStrategyExtendBO.setAgeSuggest(platformStrategyExtendBO.getAgeSuggest());
        platformStrategyExtendBO.setExtra(JSONObject.parseObject(platformStrategyDetailPO.getExtra(), PlatformStrategyExtendBO.Extra.class));
        platformStrategyExtendBO.setInstructions(JSONObject.parseObject(platformStrategyDetailPO.getInstructions(), PlatformStrategyExtendBO.Instructions.class));
        platformStrategyExtendBO.setSecuritySuggest(JSONObject.parseObject(platformStrategyDetailPO.getSecuritySuggest(), PlatformStrategyExtendBO.SecuritySuggest.class));
        platformStrategyExtendBO.setTravelSuggest(JSONObject.parseObject(platformStrategyDetailPO.getTravelSuggest(), PlatformStrategyExtendBO.TravelSuggest.class));
        platformStrategyExtendBO.setStrategyId(platformStrategyDetailPO.getId());
        return platformStrategyExtendBO;
    }

    public static PlatformStrategyDetailBO convertToPlatformStrategyDetailBO(PlatformStrategyDO platformStrategyDO) {
        if (platformStrategyDO == null) {
            return null;
        }
        PlatformStrategyDetailBO platformStrategyDetailBO = new PlatformStrategyDetailBO();
        platformStrategyDetailBO.setPlatformStrategyBO(buildToPlatformStrategyBO(platformStrategyDO));
        platformStrategyDetailBO.setPlatformStrategyExtendBO(buildToStrategyExtendBO(platformStrategyDO));
        return platformStrategyDetailBO;
    }

    private static PlatformStrategyExtendBO buildToStrategyExtendBO(PlatformStrategyDO platformStrategyDO) {
        if (platformStrategyDO == null || platformStrategyDO.getStrategyDetail() == null) {
            return null;
        }
        PlatformStrategyDO.StrategyDetail strategyDetail = platformStrategyDO.getStrategyDetail();
        PlatformStrategyExtendBO platformStrategyExtendBO = new PlatformStrategyExtendBO();
        platformStrategyExtendBO.setAgeSuggest(strategyDetail.getAgeSuggest());
        platformStrategyExtendBO.setExtra(JSONObject.parseObject(strategyDetail.getExtra(), PlatformStrategyExtendBO.Extra.class));
        platformStrategyExtendBO.setInstructions(JSONObject.parseObject(strategyDetail.getInstructions(), PlatformStrategyExtendBO.Instructions.class));
        platformStrategyExtendBO.setSecuritySuggest(JSONObject.parseObject(strategyDetail.getSecuritySuggest(), PlatformStrategyExtendBO.SecuritySuggest.class));
        platformStrategyExtendBO.setTravelSuggest(JSONObject.parseObject(strategyDetail.getTravelSuggest(), PlatformStrategyExtendBO.TravelSuggest.class));
        platformStrategyExtendBO.setStrategyId(platformStrategyDO.getId());
        return platformStrategyExtendBO;
    }

    private static PlatformStrategyBO buildToPlatformStrategyBO(PlatformStrategyDO platformStrategyDO) {
        if (platformStrategyDO == null || platformStrategyDO.getBaseStrategyInfo() == null) {
            return null;
        }
        PlatformStrategyDO.BaseStrategyInfo baseStrategyInfo = platformStrategyDO.getBaseStrategyInfo();
        PlatformStrategyBO platformStrategyBO = new PlatformStrategyBO();
        platformStrategyBO.setAllowComment(AllowedCommentEnum.getByType(baseStrategyInfo.getAllowComment()));
        platformStrategyBO.setCity(baseStrategyInfo.getCity());
        platformStrategyBO.setReferenceCount(baseStrategyInfo.getReferenceCount());
        platformStrategyBO.setCreateUser(platformStrategyDO.getCreateUser());
        platformStrategyBO.setScore(baseStrategyInfo.getScore());
        platformStrategyBO.setProvince(baseStrategyInfo.getProvince());
        platformStrategyBO.setStatus(StrategyStatusEnum.getByType(baseStrategyInfo.getStatus()));
        platformStrategyBO.setStrategyType(StrategyTypeEnum.getByType(baseStrategyInfo.getStrategyType()));
        platformStrategyBO.setTimeCost(baseStrategyInfo.getTimeCost());
        platformStrategyBO.setTravelTimeType(TravelDayTypeEnum.getByType(baseStrategyInfo.getTravelTimeType()));
        platformStrategyBO.setTitle(baseStrategyInfo.getTitle());
        platformStrategyBO.setMainImg(baseStrategyInfo.getMainImg());
        platformStrategyBO.setMoneyCost(baseStrategyInfo.getMoneyCost());
        platformStrategyBO.setRecommendDesc(baseStrategyInfo.getRecommendDesc());
        platformStrategyBO.setIsFree(baseStrategyInfo.getIsFree());
        platformStrategyBO.setViewCount(baseStrategyInfo.getViewCount());
        platformStrategyBO.setLikeCount(baseStrategyInfo.getLikeCount());
        platformStrategyBO.setCollectCount(baseStrategyInfo.getCollectCount());
        platformStrategyBO.setCommentCount(baseStrategyInfo.getCommentCount());
        platformStrategyBO.setRecommendMonth(JSONObject.parseArray(baseStrategyInfo.getRecommendMonth(), String.class));
        platformStrategyBO.setStrategyId(platformStrategyDO.getId());
        platformStrategyBO.setLastUpdateUser(platformStrategyDO.getLastUpdateUser());
        return platformStrategyBO;

    }

    public static List<StrategyInfoBO> convertToStrategyInfoBOList(List<StrategyInfoPO> strategyInfoPOList) {
        if (strategyInfoPOList == null) {
            return Lists.newArrayList();
        }
        return strategyInfoPOList.stream().map(StrategyConvert::convertToStrategyInfoBO).collect(Collectors.toList());
    }

    public static BasicStrategyBO convertToBasicStrategyBO(BasicStrategyEntity entity) {
        if (entity == null) {
            return null;
        }
        BasicStrategyBO basicStrategyBO = new BasicStrategyBO();
        basicStrategyBO.setId(entity.getMysqlId());
        basicStrategyBO.setTitle(entity.getTitle());
        basicStrategyBO.setMainImg(entity.getMainImg());
        basicStrategyBO.setStrategyType(StrategyTypeEnum.getByType(entity.getStrategyType()));
        basicStrategyBO.setViewCount(entity.getViewCount());
        basicStrategyBO.setLikeCount(entity.getLikeCount());
        basicStrategyBO.setCollectCount(entity.getCollectCount());
        basicStrategyBO.setCommentCount(entity.getCommentCount());
        basicStrategyBO.setScore(entity.getScore());
        basicStrategyBO.setTimeCost(entity.getTimeCost());
        basicStrategyBO.setMoneyCost(entity.getMoneyCost());
        basicStrategyBO.setRecommendDesc(entity.getRecommendDesc());
        basicStrategyBO.setTravelTimeType(TravelDayTypeEnum.getByType(entity.getTravelTimeType()));
        basicStrategyBO.setProvince(entity.getProvince());
        basicStrategyBO.setCity(entity.getCity());
        basicStrategyBO.setIsPlatform(entity.getIsPlatform());
        basicStrategyBO.setStatus(StrategyStatusEnum.getByType(entity.getStatus()));
        return basicStrategyBO;
    }

    public static BasicStrategyEntity buildBasicStrategyEntity(StrategyInfoBO strategyInfoBO, PlanSetBO planSetBO) {
        if (strategyInfoBO == null) {
            return null;
        }
        BasicStrategyEntity entity = new BasicStrategyEntity();
        entity.setMysqlId(strategyInfoBO.getId());
        entity.setIsPlatform(0);
        entity.setTitle(strategyInfoBO.getTitle());
        entity.setMainImg(strategyInfoBO.getMainImg());
        entity.setStrategyType(planSetBO.getPlanType().getType());
        entity.setViewCount(strategyInfoBO.getViewCount());
        entity.setLikeCount(strategyInfoBO.getLikeCount());
        entity.setCollectCount(strategyInfoBO.getCollectCount());
        entity.setCommentCount(strategyInfoBO.getCommentCount());
        entity.setScore(0);
        entity.setTimeCost(planSetBO.getPlanUseTime());
        entity.setMoneyCost(planSetBO.getPlanMoneySpend());
        if (strategyInfoBO.getSuggest() != null) {
            entity.setRecommendDesc(strategyInfoBO.getSuggest().getTravelSuggest());
        }
        entity.setTravelTimeType(convertToTravelTimeType(planSetBO) == null ? null : convertToTravelTimeType(planSetBO).getType());
        entity.setProvince(null);
        entity.setCity(planSetBO.getPlanCity());
        entity.setStatus(strategyInfoBO.getStatus().getType());
        return entity;
    }

    public static BasicStrategyEntity buildBasicStrategyEntity(PlatformStrategyDetailBO platformStrategyDetailBO) {
        if (platformStrategyDetailBO == null || platformStrategyDetailBO.getPlatformStrategyBO() == null) {
            return null;
        }
        PlatformStrategyBO platformStrategyBO = platformStrategyDetailBO.getPlatformStrategyBO();
        BasicStrategyEntity entity = new BasicStrategyEntity();
        entity.setMysqlId(platformStrategyBO.getStrategyId());
        entity.setIsPlatform(1);
        entity.setTitle(platformStrategyBO.getTitle());
        entity.setMainImg(platformStrategyBO.getMainImg());
        entity.setStrategyType(platformStrategyBO.getStrategyType().getType());
        entity.setViewCount(platformStrategyBO.getViewCount());
        entity.setLikeCount(platformStrategyBO.getLikeCount());
        entity.setCollectCount(platformStrategyBO.getCollectCount());
        entity.setCommentCount(platformStrategyBO.getCommentCount());
        entity.setScore(0);
        entity.setTimeCost(0);
        entity.setMoneyCost(0);
        entity.setRecommendDesc(platformStrategyBO.getRecommendDesc());
        entity.setTravelTimeType(platformStrategyBO.getTravelTimeType().getType());
        entity.setProvince(platformStrategyBO.getProvince());
        entity.setCity(platformStrategyBO.getCity());
        entity.setStatus(platformStrategyBO.getStatus().getType());
        return entity;
    }

    private static TravelDayTypeEnum convertToTravelTimeType(PlanSetBO planSetBO) {
        if (planSetBO == null) {
            return null;
        }
        if (planSetBO.getStartPlanTime() == null || planSetBO.getEndPlanTime() == null) {
            return null;
        }
        long between = DateUtil.between(planSetBO.getStartPlanTime(), planSetBO.getEndPlanTime(), DateUnit.DAY);
        if (between == 0 || between == 1) {
            return TravelDayTypeEnum.ONE_DAY;
        } else if (between == 2) {
            return TravelDayTypeEnum.TWE_DAY;
        } else if (between == 3) {
            return TravelDayTypeEnum.THREE_DAY;
        } else if (between == 4) {
            return TravelDayTypeEnum.FOUR_DAY;
        } else if (between == 5) {
            return TravelDayTypeEnum.FIVE_DAY;
        } else if (between == 6) {
            return TravelDayTypeEnum.SIX_DAY;
        } else if (between == 7) {
            return TravelDayTypeEnum.SEVEN_DAY;
        } else if (between <= 10) {
            return TravelDayTypeEnum.MINOR_VACATION;
        } else if (between <= 15) {
            return TravelDayTypeEnum.FIFTEEN_DAY;
        } else {
            return TravelDayTypeEnum.HOLIDAY;
        }
    }

    public static PlanSetDetailResponse convertToPlanSetDetailResponse(PlanSetBO planSetBO) {
        if (planSetBO == null) {
            return null;
        }
        PlanSetDetailResponse response = new PlanSetDetailResponse();
        response.setPlanId(planSetBO.getPlanId());
        response.setUserId(planSetBO.getUserId());
        response.setTitle(planSetBO.getTitle());
        response.setDesc(planSetBO.getDesc());
        response.setMainImg(planSetBO.getMainImg());
        response.setStartPlanTime(planSetBO.getStartPlanTime());
        response.setEndPlanTime(planSetBO.getEndPlanTime());
        response.setPlanCity(planSetBO.getPlanCity());
        response.setPlanUseTime(planSetBO.getPlanUseTime());
        response.setPlanMoneySpend(planSetBO.getPlanMoneySpend());
        response.setRelationCount(planSetBO.getRelationCount());
        response.setPlanType(planSetBO.getPlanType());
        response.setStatus(planSetBO.getStatus());
        response.setIsTravel(planSetBO.getIsTravel());
        response.setTravelStatus(planSetBO.getTravelStatus());
        return response;
    }

    public static PlanSetInfoResponse convertToPlanSetInfoResponse(PlanSetBO planSetBO) {
        if (planSetBO == null) {
            return null;
        }
        PlanSetInfoResponse response = new PlanSetInfoResponse();
        response.setPlanId(planSetBO.getPlanId());
        response.setUserId(planSetBO.getUserId());
        response.setTitle(planSetBO.getTitle());
        response.setDesc(planSetBO.getDesc());
        response.setMainImg(planSetBO.getMainImg());
        response.setStartPlanTime(planSetBO.getStartPlanTime());
        response.setEndPlanTime(planSetBO.getEndPlanTime());
        response.setPlanCity(planSetBO.getPlanCity());
        response.setPlanUseTime(planSetBO.getPlanUseTime());
        response.setPlanMoneySpend(planSetBO.getPlanMoneySpend());
        response.setRelationCount(planSetBO.getRelationCount());
        response.setPlanType(planSetBO.getPlanType());
        response.setStatus(planSetBO.getStatus());
        response.setIsTravel(planSetBO.getIsTravel());
        response.setTravelStatus(planSetBO.getTravelStatus());
        return response;
    }

    public static List<PlanSetInfoResponse> convertToPlanSetInfoResponseList(List<PlanSetBO> planSetBOS) {
        if (CollectionUtil.isEmpty(planSetBOS)) {
            return Lists.newArrayList();
        }
        return planSetBOS.stream().map(StrategyConvert::convertToPlanSetInfoResponse).collect(Collectors.toList());
    }

    public static PlatformStrategyBaseResponse convertToPlatformStrategyBaseResponse(PlatformStrategyBO platformStrategyBO) {
        if (platformStrategyBO == null) {
            return null;
        }
        PlatformStrategyBaseResponse response = new PlatformStrategyBaseResponse();
        response.setStrategyId(platformStrategyBO.getStrategyId());
        response.setTitle(platformStrategyBO.getTitle());
        response.setRecommendDesc(platformStrategyBO.getRecommendDesc());
        response.setStrategyType(platformStrategyBO.getStrategyType());
        response.setTravelTimeType(platformStrategyBO.getTravelTimeType());
        response.setRecommendMonth(platformStrategyBO.getRecommendMonth());
        response.setMainImg(platformStrategyBO.getMainImg());
        response.setProvince(platformStrategyBO.getProvince());
        response.setCity(platformStrategyBO.getCity());
        response.setMoneyCost(platformStrategyBO.getMoneyCost());
        response.setTimeCost(platformStrategyBO.getTimeCost());
        response.setScore(platformStrategyBO.getScore());
        response.setStatus(platformStrategyBO.getStatus());
        response.setIsFree(platformStrategyBO.getIsFree());
        response.setAllowComment(platformStrategyBO.getAllowComment());
        response.setReferenceCount(platformStrategyBO.getReferenceCount());
        response.setViewCount(platformStrategyBO.getViewCount());
        response.setLikeCount(platformStrategyBO.getLikeCount());
        response.setCollectCount(platformStrategyBO.getCollectCount());
        response.setCommentCount(platformStrategyBO.getCommentCount());
        return response;
    }

    public static List<PlatformStrategyBaseResponse> convertToPlatformStrategyBaseResponseList(List<PlatformStrategyBO> platformStrategyBOS) {
        if (CollectionUtil.isEmpty(platformStrategyBOS)) {
            return Lists.newArrayList();
        }
        return platformStrategyBOS.stream().map(StrategyConvert::convertToPlatformStrategyBaseResponse).collect(Collectors.toList());
    }

    public static PlatformStrategyDetailResponse convertToPlatformStrategyDetailResponse(PlatformStrategyDetailBO platformStrategyDetailBO) {
        if (platformStrategyDetailBO == null || platformStrategyDetailBO.getPlatformStrategyBO() == null) {
            return null;
        }
        PlatformStrategyDetailResponse response = new PlatformStrategyDetailResponse();
        PlatformStrategyBO platformStrategyBO = platformStrategyDetailBO.getPlatformStrategyBO();
        response.setStrategyId(platformStrategyBO.getStrategyId());
        response.setTitle(platformStrategyBO.getTitle());
        response.setRecommendDesc(platformStrategyBO.getRecommendDesc());
        response.setStrategyType(platformStrategyBO.getStrategyType());
        response.setTravelTimeType(platformStrategyBO.getTravelTimeType());
        response.setRecommendMonth(platformStrategyBO.getRecommendMonth());
        response.setMainImg(platformStrategyBO.getMainImg());
        response.setProvince(platformStrategyBO.getProvince());
        response.setCity(platformStrategyBO.getCity());
        response.setMoneyCost(platformStrategyBO.getMoneyCost());
        response.setTimeCost(platformStrategyBO.getTimeCost());
        response.setScore(platformStrategyBO.getScore());
        response.setStatus(platformStrategyBO.getStatus());
        response.setIsFree(platformStrategyBO.getIsFree());
        response.setAllowComment(platformStrategyBO.getAllowComment());
        response.setReferenceCount(platformStrategyBO.getReferenceCount());
        response.setViewCount(platformStrategyBO.getViewCount());
        response.setLikeCount(platformStrategyBO.getLikeCount());
        response.setCollectCount(platformStrategyBO.getCollectCount());
        response.setCommentCount(platformStrategyBO.getCommentCount());

        if (platformStrategyDetailBO.getPlatformStrategyExtendBO() != null) {
            PlatformStrategyExtendBO platformStrategyExtendBO = platformStrategyDetailBO.getPlatformStrategyExtendBO();
            response.setAgeSuggest(platformStrategyExtendBO.getAgeSuggest());
            if (platformStrategyExtendBO.getTravelSuggest() != null) {
                PlatformStrategyDetailResponse.TravelSuggest travelSuggest = new PlatformStrategyDetailResponse.TravelSuggest();
                travelSuggest.setTravelSuggest(platformStrategyExtendBO.getTravelSuggest().getTravelSuggest());
                travelSuggest.setEssentialItems(platformStrategyExtendBO.getTravelSuggest().getEssentialItems());
                travelSuggest.setSuggestCarry(platformStrategyExtendBO.getTravelSuggest().getSuggestCarry());
                travelSuggest.setSeasonSuggest(platformStrategyExtendBO.getTravelSuggest().getSeasonSuggest());
                travelSuggest.setDisclose(platformStrategyExtendBO.getTravelSuggest().getDisclose());
                response.setTravelSuggest(travelSuggest);
            }
            if (platformStrategyExtendBO.getInstructions() != null) {
                PlatformStrategyDetailResponse.Instructions instructions = new PlatformStrategyDetailResponse.Instructions();
                instructions.setDifficultyLevel(platformStrategyExtendBO.getInstructions().getDifficultyLevel());
                instructions.setLocalCulture(platformStrategyExtendBO.getInstructions().getLocalCulture());
                response.setInstructions(instructions);
            }
            if (platformStrategyExtendBO.getSecuritySuggest() != null) {
                PlatformStrategyDetailResponse.SecuritySuggest securitySuggest = new PlatformStrategyDetailResponse.SecuritySuggest();
                securitySuggest.setTravelLimit(platformStrategyExtendBO.getSecuritySuggest().getTravelLimit());
                securitySuggest.setBaseAttention(platformStrategyExtendBO.getSecuritySuggest().getBaseAttention());
                securitySuggest.setOutDoorAttention(platformStrategyExtendBO.getSecuritySuggest().getOutDoorAttention());
                securitySuggest.setAssistance(platformStrategyExtendBO.getSecuritySuggest().getAssistance());
                response.setSecuritySuggest(securitySuggest);
            }
            if (platformStrategyExtendBO.getExtra() != null) {
                response.setImgList(platformStrategyExtendBO.getExtra().getImgList());
            }
        }
        return response;
    }

    public static UserStrategyBaseResponse convertToUserStrategyBaseResponse(StrategyInfoBO strategyInfoBO) {
        if (strategyInfoBO == null) {
            return null;
        }
        UserStrategyBaseResponse response = new UserStrategyBaseResponse();
        response.setId(strategyInfoBO.getId());
        response.setUserId(strategyInfoBO.getUserId());
        response.setPlanId(strategyInfoBO.getPlanId());
        response.setTitle(strategyInfoBO.getTitle());
        response.setIsPrivate(strategyInfoBO.getIsPrivate());
        response.setIsAssociatePlanContent(strategyInfoBO.getIsAssociatePlanContent());
        response.setStatus(strategyInfoBO.getStatus());
        response.setAllowComment(strategyInfoBO.getAllowComment());
        response.setSource(strategyInfoBO.getSource());
        response.setMainImg(strategyInfoBO.getMainImg());
        response.setReferenceCount(strategyInfoBO.getReferenceCount());
        response.setViewCount(strategyInfoBO.getViewCount());
        response.setLikeCount(strategyInfoBO.getLikeCount());
        response.setCollectCount(strategyInfoBO.getCollectCount());
        response.setCommentCount(strategyInfoBO.getCommentCount());
        return response;
    }

    public static UserStrategyDetailResponse convertToUserStrategyDetailResponse(StrategyInfoBO strategyInfoBO) {
        if (strategyInfoBO == null) {
            return null;
        }
        UserStrategyDetailResponse response = new UserStrategyDetailResponse();
        response.setId(strategyInfoBO.getId());
        response.setUserId(strategyInfoBO.getUserId());
        response.setPlanId(strategyInfoBO.getPlanId());
        response.setTitle(strategyInfoBO.getTitle());
        response.setIsPrivate(strategyInfoBO.getIsPrivate());
        response.setIsAssociatePlanContent(strategyInfoBO.getIsAssociatePlanContent());
        response.setStatus(strategyInfoBO.getStatus());
        response.setAllowComment(strategyInfoBO.getAllowComment());
        response.setSource(strategyInfoBO.getSource());
        response.setMainImg(strategyInfoBO.getMainImg());
        response.setReferenceCount(strategyInfoBO.getReferenceCount());
        response.setViewCount(strategyInfoBO.getViewCount());
        response.setLikeCount(strategyInfoBO.getLikeCount());
        response.setCollectCount(strategyInfoBO.getCollectCount());
        response.setCommentCount(strategyInfoBO.getCommentCount());
        if (strategyInfoBO.getExtra() != null) {

        }
        if (strategyInfoBO.getGuide() != null) {
            UserStrategyDetailResponse.TravelGuide travelGuide = new UserStrategyDetailResponse.TravelGuide();
            travelGuide.setCityExp(strategyInfoBO.getGuide().getCityExp());
            travelGuide.setPlayExp(strategyInfoBO.getGuide().getPlayExp());
            travelGuide.setTravelExp(strategyInfoBO.getGuide().getTravelExp());
            travelGuide.setFoodExp(strategyInfoBO.getGuide().getFoodExp());
            response.setGuide(travelGuide);
        }
        if (strategyInfoBO.getSuggest() != null) {
            UserStrategyDetailResponse.Suggest suggest = new UserStrategyDetailResponse.Suggest();
            suggest.setTravelSuggest(strategyInfoBO.getSuggest().getTravelSuggest());
            suggest.setSecuritySuggest(strategyInfoBO.getSuggest().getSecuritySuggest());
            suggest.setDefectSuggest(strategyInfoBO.getSuggest().getDefectSuggest());
            suggest.setDisclose(strategyInfoBO.getSuggest().getDisclose());
            response.setSuggest(suggest);
        }
        return response;
    }

    public static List<UserStrategyBaseResponse> convertToUserStrategyBaseResponseList(List<StrategyInfoBO> strategyInfoBOS) {
        if (CollectionUtils.isEmpty(strategyInfoBOS)) {
            return Lists.newArrayList();
        }
        return strategyInfoBOS.stream().map(StrategyConvert::convertToUserStrategyBaseResponse).collect(Collectors.toList());
    }

    public static UserStrategyDetailResp buildUserStrategyDetailResp(PlanSetBO planSetBO, StrategyInfoBO strategyInfoBO) {
        if (planSetBO == null || strategyInfoBO == null) {
            return null;
        }
        UserStrategyDetailResp resp = new UserStrategyDetailResp();
        resp.setPlanId(String.valueOf(planSetBO.getPlanId()));
        resp.setStrategyId(String.valueOf(strategyInfoBO.getId()));
        resp.setUserId(String.valueOf(planSetBO.getUserId()));
        resp.setPlanSetResp(buildUserStrategyDetailPlanSetResp(planSetBO));
        resp.setStrategyInfoResp(buildUserStrategyDetailStrategyInfoResp(strategyInfoBO));
        return resp;
    }

    private static UserStrategyDetailResp.StrategyInfoResp buildUserStrategyDetailStrategyInfoResp(StrategyInfoBO strategyInfoBO) {
        if (strategyInfoBO == null) {
            return null;
        }
        UserStrategyDetailResp.StrategyInfoResp resp = new UserStrategyDetailResp.StrategyInfoResp();
        resp.setTitle(strategyInfoBO.getTitle());
        resp.setStatus(strategyInfoBO.getStatus() == null ? null : strategyInfoBO.getStatus().getType());
        resp.setStatusStr(strategyInfoBO.getStatus() == null ? null : strategyInfoBO.getStatus().getName());
        resp.setIsAssociatePlanContent(strategyInfoBO.getIsAssociatePlanContent());
        if (strategyInfoBO.getSuggest() != null) {
            StrategyInfoBO.Suggest originSuggest = strategyInfoBO.getSuggest();
            UserStrategyDetailResp.Suggest suggest = new UserStrategyDetailResp.Suggest();
            suggest.setTravelSuggest(originSuggest.getTravelSuggest());
            suggest.setSecuritySuggest(originSuggest.getSecuritySuggest());
            suggest.setDefectSuggest(originSuggest.getDefectSuggest());
            suggest.setDisclose(originSuggest.getDisclose());
            resp.setSuggest(suggest);
        }
        if (strategyInfoBO.getGuide() != null) {
            UserStrategyDetailResp.TravelGuide guide = new UserStrategyDetailResp.TravelGuide();
            guide.setCityExp(strategyInfoBO.getGuide().getCityExp());
            guide.setPlayExp(strategyInfoBO.getGuide().getPlayExp());
            guide.setTravelExp(strategyInfoBO.getGuide().getTravelExp());
            guide.setFoodExp(strategyInfoBO.getGuide().getFoodExp());
            resp.setGuide(guide);
        }
        resp.setSource(strategyInfoBO.getSource() == null ? null : strategyInfoBO.getSource().getCode());
        resp.setMainImg(strategyInfoBO.getMainImg());
        resp.setReferenceCount(strategyInfoBO.getReferenceCount());
        resp.setViewCount(strategyInfoBO.getViewCount());
        resp.setLikeCount(strategyInfoBO.getLikeCount());
        resp.setCommentCount(strategyInfoBO.getCommentCount());
        resp.setIsPrivate(strategyInfoBO.getIsPrivate() == null ? null : strategyInfoBO.getIsPrivate().getType());
        resp.setIsPrivateStr(strategyInfoBO.getIsPrivate() == null ? null : strategyInfoBO.getIsPrivate().getName());
        resp.setAllowComment(strategyInfoBO.getAllowComment() == null ? null : strategyInfoBO.getAllowComment().getType());
        resp.setCollectCount(strategyInfoBO.getCollectCount());
        return resp;
    }

    private static UserStrategyDetailResp.PlanSetResp buildUserStrategyDetailPlanSetResp(PlanSetBO planSetBO) {
        if (planSetBO == null) {
            return null;
        }
        UserStrategyDetailResp.PlanSetResp resp = new UserStrategyDetailResp.PlanSetResp();
        resp.setPlanCity(planSetBO.getPlanCity());
        resp.setPlanUseTime(planSetBO.getPlanUseTime());
        resp.setStartPlanTime(planSetBO.getStartPlanTime());
        resp.setEndPlanTime(planSetBO.getEndPlanTime());
        resp.setRelationCount(planSetBO.getRelationCount());
        resp.setDesc(planSetBO.getDesc());
        resp.setMainImg(planSetBO.getMainImg());
        resp.setPlanMoneySpend(planSetBO.getPlanMoneySpend());
        resp.setTitle(planSetBO.getTitle());
        resp.setTravelStatus(planSetBO.getTravelStatus());
        resp.setIsPrivate(planSetBO.getIsPrivate() == null ? null : planSetBO.getIsPrivate().getType());
        resp.setIsTravel(planSetBO.getIsTravel());
        resp.setStatus(planSetBO.getStatus() == null ? null : planSetBO.getStatus().getType());
        return resp;
    }

    public static PlanSetConditionBO convertToPlanSetConditionBO(QueryUserStrategyByConditionReq req) {
        if (req == null) {
            return null;
        }
        PlanSetConditionBO conditionBO = new PlanSetConditionBO();
        conditionBO.setCurrentIndex(req.getCurrentIndex());
        conditionBO.setPageSize(req.getPageSize());
        conditionBO.setPageIndex(req.getPageIndex());
        conditionBO.setUserId(req.getUserId());
        conditionBO.setTitle(req.getTitle());
        conditionBO.setStatus(req.getStatus());
        conditionBO.setPlanId(req.getPlanId());
        return conditionBO;
    }

    public static PageResult<QueryUserStrategyByConditionResp> convertToQueryUserStrategyByConditionRespPage(PageResult<PlanSetBO> pageResult) {
        if (pageResult == null) {
            return null;
        }
        if (CollectionUtils.isEmpty(pageResult.getResults())) {
            return PageResult.of(null, pageResult.getPageNum(), pageResult.getPageSize(), pageResult.getTotal());
        }
        PageResult<QueryUserStrategyByConditionResp> respPageResult = new PageResult<>();
        respPageResult.setPageNum(pageResult.getPageNum());
        respPageResult.setPageSize(pageResult.getPageSize());
        respPageResult.setTotal(pageResult.getTotal());
        respPageResult.setPageCount(pageResult.getPageCount());
        respPageResult.setCurrentIndex(pageResult.getCurrentIndex());
        respPageResult.setHasNext(pageResult.isHasNext());
        respPageResult.setResults(pageResult.getResults().stream().map(StrategyConvert::convertToQueryUserStrategyByConditionResp).collect(Collectors.toList()));
        return respPageResult;
    }

    private static QueryUserStrategyByConditionResp convertToQueryUserStrategyByConditionResp(PlanSetBO planSetBO) {
        if (planSetBO == null) {
            return null;
        }
        QueryUserStrategyByConditionResp resp = new QueryUserStrategyByConditionResp();
        resp.setPlanId(planSetBO.getPlanId());
        resp.setPlanType(planSetBO.getPlanType() == null ? null : planSetBO.getPlanType().getType());
        resp.setPlanTypeStr(planSetBO.getPlanType() == null ? null : planSetBO.getPlanType().getName());
        resp.setPlanCity(planSetBO.getPlanCity());
        resp.setStatus(planSetBO.getStatus() == null ? StrategyStatusEnum.PUBLISHED.getType() : planSetBO.getStatus().getType());
        resp.setTitle(planSetBO.getTitle());
        resp.setMainImg(planSetBO.getMainImg());
        resp.setStartPlanTime(planSetBO.getStartPlanTime());
        resp.setEndPlanTime(planSetBO.getEndPlanTime());
        resp.setRelationCount(planSetBO.getRelationCount());
        resp.setUserId(planSetBO.getUserId());
        resp.setTravelStatus(planSetBO.getTravelStatus());
        resp.setIsTravel(planSetBO.getIsTravel());
        return resp;

    }

    public static List<UserStrategyRelationResp> buildUserStrategyRelationRespList(List<PlanRelationBO> planRelationBOS, List<PlanContentBO> planContentBOS) {
        if (CollectionUtils.isEmpty(planRelationBOS)) {
            return Lists.newArrayList();
        }
        Long planId = planRelationBOS.get(0).getBusinessId();
        Map<Long/*planRelationId*/, PlanContentBO> planContentBOMap = new HashMap<>();
        if (CollectionUtils.isNotEmpty(planContentBOS)) {
            planContentBOMap = planContentBOS.stream().collect(Collectors.toMap(PlanContentBO::getPlanRelationId, Function.identity(), (k1, k2) -> k1));
        }
        List<UserStrategyRelationResp> respList = new ArrayList<>(planRelationBOS.size());
        Map<Integer, List<PlanRelationBO>> collect = planRelationBOS.stream().collect(Collectors.groupingBy(PlanRelationBO::getPlanDay));
        for (Integer day : collect.keySet()) {
            UserStrategyRelationResp resp = new UserStrategyRelationResp();
            List<PlanRelationBO> planRelationBOList = collect.get(day);
            resp.setPlanId(planId);
            resp.setCurrentDay(day);
            List<UserStrategyRelationResp.DayRelation> dayRelationList = new ArrayList<>(planRelationBOList.size());

            for (PlanRelationBO planRelationBO : planRelationBOList) {
                UserStrategyRelationResp.RelationInfo relationInfo = new UserStrategyRelationResp.RelationInfo();
                relationInfo.setRelationName(planRelationBO.getRelationName());
                relationInfo.setTitle(planRelationBO.getTitle());
                relationInfo.setStartTime(planRelationBO.getStartTime());
                relationInfo.setRemark(planRelationBO.getRemark());
                relationInfo.setRelationType(planRelationBO.getRelationType().getType());
                relationInfo.setIsTravel(planRelationBO.getIsTravel() ? 1 : 0);
                relationInfo.setRelationId(planRelationBO.getId());
                relationInfo.setTimeCost(planRelationBO.getTimeCost());
                relationInfo.setStartTime(planRelationBO.getStartTime());


                PlanContentBO planContentBO = planContentBOMap.get(planRelationBO.getId());
                UserStrategyRelationResp.RelationContent relationContent = new UserStrategyRelationResp.RelationContent();
                UserStrategyRelationResp.DayRelation dayRelation = new UserStrategyRelationResp.DayRelation();
                if (planContentBO != null) {
                    relationContent.setContent(planContentBO.getContent());
                    relationContent.setScore(planContentBO.getScore());
                    relationContent.setTitle(planContentBO.getTitle());
                    if (planContentBO.getTravelSuggest() != null) {
                        UserStrategyRelationResp.Suggest suggest = new UserStrategyRelationResp.Suggest();
                        suggest.setTravelSuggest(planContentBO.getTravelSuggest().getTravelSuggest());
                        suggest.setSightSuggest(planContentBO.getTravelSuggest().getSightSuggest());
                        suggest.setDefectSuggest(planContentBO.getTravelSuggest().getDefectSuggest());
                        suggest.setDisclose(planContentBO.getTravelSuggest().getDisclose());
                        relationContent.setTravelSuggest(suggest);
                    }
                    if (planContentBO.getExtraInfo() != null) {
                        UserStrategyRelationResp.ExtraInfo extraInfo = new UserStrategyRelationResp.ExtraInfo();
                        extraInfo.setMoneyCost(planContentBO.getExtraInfo().getMoneyCost());
                        extraInfo.setTimeCost(planContentBO.getExtraInfo().getTimeCost());
                        extraInfo.setImgList(planContentBO.getExtraInfo().getImgList());
                        relationContent.setExtraInfo(extraInfo);
                    }
                    dayRelation.setRelationContent(relationContent);
                }

                dayRelation.setRelationId(planRelationBO.getId());
                dayRelation.setRelationInfo(relationInfo);
                dayRelationList.add(dayRelation);
            }
            resp.setDayRelation(dayRelationList);
            respList.add(resp);
        }
        return respList;
    }

    public static PlatformStrategyRelationDetailVO buildPlatformStrategyRelationDetailVO(PlatformStrategyDetailBO platformStrategyDetailBO, List<PlanRelationBO> planRelationBOList) {
        if (platformStrategyDetailBO == null || CollectionUtils.isEmpty(planRelationBOList)) {
            return null;
        }
        PlatformStrategyRelationDetailVO response = new PlatformStrategyRelationDetailVO();
        response.setStrategyId(String.valueOf(platformStrategyDetailBO.getPlatformStrategyBO().getStrategyId()));
        response.setPlatformStrategyInfoVO(convertToPlatformStrategyInfoVO(platformStrategyDetailBO));
        response.setPlanRelationInfoVO(convertPlanRelationInfoVOList(planRelationBOList));
        response.setBaseUserVO(buildPlatformDefaultUserVO());
        return response;
    }

    public static BasicStrategyEntity buildUpdateBasicStrategyEntity(PlatformStrategyDO alreadyData, PlatformStrategyDO platformStrategyDO) {
        if (alreadyData == null || platformStrategyDO == null){
            return null;
        }
        PlatformStrategyDetailBO DetailBO = convertToPlatformStrategyDetailBO(alreadyData);
        PlatformStrategyDetailBO platformStrategyDetailBO = convertToPlatformStrategyDetailBO(platformStrategyDO);
        PlatformStrategyBO alreadyStrategyBO = DetailBO.getPlatformStrategyBO();
        PlatformStrategyBO platformStrategyBO = platformStrategyDetailBO.getPlatformStrategyBO();
        BasicStrategyEntity entity = new BasicStrategyEntity();
        entity.setMysqlId(DetailBO.getPlatformStrategyBO().getStrategyId());
        entity.setIsPlatform(1);
        if (!alreadyStrategyBO.getTitle().equals(platformStrategyBO.getTitle())) {
            entity.setTitle(platformStrategyBO.getTitle());
        }
        if (!alreadyStrategyBO.getMainImg().equals(platformStrategyBO.getMainImg())) {
            entity.setMainImg(platformStrategyBO.getMainImg());
        }
        if (!alreadyStrategyBO.getRecommendDesc().equals(platformStrategyBO.getRecommendDesc())) {
            entity.setRecommendDesc(platformStrategyBO.getRecommendDesc());
        }
        if (!alreadyStrategyBO.getProvince().equals(platformStrategyBO.getProvince())) {
            entity.setProvince(platformStrategyBO.getProvince());
        }
        if (!alreadyStrategyBO.getCity().equals(platformStrategyBO.getCity())) {
            entity.setCity(platformStrategyBO.getCity());
        }
        return entity;
    }
}
